Skip to content

Commit 8a17bff

Browse files
committed
Add new Item methods
1 parent fc35d80 commit 8a17bff

File tree

4 files changed

+125
-3
lines changed

4 files changed

+125
-3
lines changed

methods/CMangos/ItemMethods.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,13 @@ namespace LuaItem
861861
{ "SaveToDB", &LuaItem::SaveToDB },
862862

863863
// Not implemented methods
864-
{ "IsRefundExpired", METHOD_REG_NONE } // not implemented
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
865871
};
866872
};
867873
#endif

methods/Mangos/ItemMethods.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,13 @@ namespace LuaItem
867867
{ "SaveToDB", &LuaItem::SaveToDB },
868868

869869
// Not implemented methods
870-
{ "IsRefundExpired", METHOD_REG_NONE } // not implemented
870+
{ "IsRefundExpired", METHOD_REG_NONE }, // not implemented
871+
{ "GetStatInfo", METHOD_REG_NONE }, // not implemented
872+
{ "GetDamageInfo", METHOD_REG_NONE }, // not implemented
873+
{ "GetSpeed", METHOD_REG_NONE }, // not implemented
874+
{ "GetArmor", METHOD_REG_NONE }, // not implemented
875+
{ "GetMaxDurability", METHOD_REG_NONE }, // not implemented
876+
{ "GetDurability", METHOD_REG_NONE } // not implemented
871877
};
872878
};
873879
#endif

methods/TrinityCore/ItemMethods.h

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,104 @@ namespace LuaItem
609609
return 1;
610610
}
611611

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

811915
// Setters
812916
{ "SetOwner", &LuaItem::SetOwner },

methods/VMangos/ItemMethods.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,13 @@ namespace LuaItem
721721
{ "IsCurrencyToken", METHOD_REG_NONE }, // not implemented
722722
{ "IsBoundAccountWide", METHOD_REG_NONE }, // not implemented
723723
{ "IsWeaponVellum", METHOD_REG_NONE }, // not implemented
724-
{ "IsArmorVellum", METHOD_REG_NONE } // not implemented
724+
{ "IsArmorVellum", METHOD_REG_NONE }, // not implemented
725+
{ "GetStatInfo", METHOD_REG_NONE }, // not implemented
726+
{ "GetDamageInfo", METHOD_REG_NONE }, // not implemented
727+
{ "GetSpeed", METHOD_REG_NONE }, // not implemented
728+
{ "GetArmor", METHOD_REG_NONE }, // not implemented
729+
{ "GetMaxDurability", METHOD_REG_NONE }, // not implemented
730+
{ "GetDurability", METHOD_REG_NONE } // not implemented
725731
};
726732
};
727733
#endif

0 commit comments

Comments
 (0)