Skip to content

Commit 1ce6a90

Browse files
Niam5Foereaper
andcommitted
Add new Item methods
Co-Authored-By: Foe <[email protected]>
1 parent 99a8c9f commit 1ce6a90

File tree

1 file changed

+105
-7
lines changed

1 file changed

+105
-7
lines changed

methods/CMangos/ItemMethods.h

Lines changed: 105 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,104 @@ namespace LuaItem
611611
}
612612
#endif
613613

614+
/**
615+
* Returns the stat info of the specified stat slot of this [Item]
616+
*
617+
* @param uint8 statSlot : the stat slot specified
618+
* @return int32 statValue
619+
* @return int32 statType
620+
*/
621+
int GetStatInfo(Eluna* E, Item* item)
622+
{
623+
uint8 statSlot = E->CHECKVAL<uint8>(2);
624+
int32 statValue = 0;
625+
int32 statType = 0;
626+
627+
if (statSlot > 0 && statSlot <= MAX_ITEM_PROTO_STATS)
628+
{
629+
auto& statEntry = item->GetTemplate()->ItemStat[statSlot - 1];
630+
statValue = statEntry.ItemStatValue;
631+
statType = statEntry.ItemStatType;
632+
}
633+
634+
E->Push(statValue);
635+
E->Push(statType);
636+
return 2;
637+
}
638+
639+
/**
640+
* Returns the damage info of the specified damage slot of this [Item]
641+
*
642+
* @param uint8 damageSlot : the damage slot specified (1 or 2)
643+
* @return uint32 damageType
644+
* @return float minDamage
645+
* @return float maxDamage
646+
*/
647+
int GetDamageInfo(Eluna* E, Item* item)
648+
{
649+
uint8 damageSlot = E->CHECKVAL<uint8>(2);
650+
uint32 damageType = 0;
651+
float damageMin = 0;
652+
float damageMax = 0;
653+
654+
if (damageSlot > 0 && damageSlot <= MAX_ITEM_PROTO_DAMAGES)
655+
{
656+
auto& damageEntry = item->GetTemplate()->Damage[damageSlot - 1];
657+
damageType = damageEntry.DamageType;
658+
damageMin = damageEntry.DamageMin;
659+
damageMax = damageEntry.DamageMax;
660+
}
661+
662+
E->Push(damageType);
663+
E->Push(damageMin);
664+
E->Push(damageMax);
665+
return 3;
666+
}
667+
668+
/**
669+
* Returns the base attack speed of this [Item]
670+
*
671+
* @return uint32 speed
672+
*/
673+
int GetSpeed(Eluna* E, Item* item)
674+
{
675+
E->Push(item->GetTemplate()->Delay);
676+
return 1;
677+
}
678+
679+
/**
680+
* Returns the base armor of this [Item]
681+
*
682+
* @return uint32 armor
683+
*/
684+
int GetArmor(Eluna* E, Item* item)
685+
{
686+
E->Push(item->GetTemplate()->Armor);
687+
return 1;
688+
}
689+
690+
/**
691+
* Returns the max durability of this [Item]
692+
*
693+
* @return uint32 maxDurability
694+
*/
695+
int GetMaxDurability(Eluna* E, Item* item)
696+
{
697+
E->Push(item->GetUInt32Value(ITEM_FIELD_MAXDURABILITY));
698+
return 1;
699+
}
700+
701+
/**
702+
* Returns the current durability of this [Item]
703+
*
704+
* @return uint32 durabiliy
705+
*/
706+
int GetDurability(Eluna* E, Item* item)
707+
{
708+
E->Push(item->GetUInt32Value(ITEM_FIELD_DURABILITY));
709+
return 1;
710+
}
711+
614712
/**
615713
* Returns the random property ID of this [Item]
616714
*
@@ -807,6 +905,12 @@ namespace LuaItem
807905
{ "GetRandomProperty", &LuaItem::GetRandomProperty },
808906
{ "GetItemSet", &LuaItem::GetItemSet },
809907
{ "GetBagSize", &LuaItem::GetBagSize },
908+
{ "GetStatInfo",& LuaItem::GetStatInfo },
909+
{ "GetDamageInfo", &LuaItem::GetDamageInfo },
910+
{ "GetSpeed", &LuaItem::GetSpeed },
911+
{ "GetArmor", &LuaItem::GetArmor },
912+
{ "GetMaxDurability", &LuaItem::GetMaxDurability },
913+
{ "GetDurability", &LuaItem::GetDurability },
810914
#if ELUNA_EXPANSION >= EXP_TBC
811915
{ "GetRandomSuffix", &LuaItem::GetRandomSuffix },
812916
#else
@@ -861,13 +965,7 @@ namespace LuaItem
861965
{ "SaveToDB", &LuaItem::SaveToDB },
862966

863967
// Not implemented methods
864-
{ "IsRefundExpired", METHOD_REG_NONE }, // not implemented
865-
{ "GetStatInfo", METHOD_REG_NONE }, // not implemented
866-
{ "GetDamageInfo", METHOD_REG_NONE }, // not implemented
867-
{ "GetSpeed", METHOD_REG_NONE }, // not implemented
868-
{ "GetArmor", METHOD_REG_NONE }, // not implemented
869-
{ "GetMaxDurability", METHOD_REG_NONE }, // not implemented
870-
{ "GetDurability", METHOD_REG_NONE } // not implemented
968+
{ "IsRefundExpired", METHOD_REG_NONE } // not implemented
871969
};
872970
};
873971
#endif

0 commit comments

Comments
 (0)