View Full Version : [SOLVED] ammo slot

09-09-2016, 05:53 PM
I'm working on a script to keep track of ammo for hunters on my TrinityCore server. I've tried a few different techniques that seem to work okay, but what I am really looking for is a way to identify which type of ammo is currently equipped and being used in combat, taking into account the fact that a hunter could conceivably have any number of different types of ammo in their bags at any given time. I saw that the Player:EquipItem and Player:GetItemByPos has some details regarding inventory and equipment slots; however, I noticed that the ammo slot is not mentioned. Is this not enumerated at all? Is there any way to detect which ammo is in the ammo slot? Or are there any suggestions on how to identify the type of ammo in use? Any feedback would be appreciated.

09-09-2016, 10:01 PM
If you take a look at Spell::TakeAmmo you can see this:

More specificly this, which seems to get the item ID used as ammo: uint32 ammo = m_caster->ToPlayer()->GetUInt32Value(PLAYER_AMMO_ID)

Eluna has the same function: http://eluna.emudevs.com/Object/GetUInt32Value.html
And on 3.3.5 PLAYER_AMMO_ID is 1198

The reason ammo is not in equipped slots is probably that it is just used from the bags. I don think it is actually "equipped" in the same sense as other items.

09-10-2016, 01:36 AM
Thank you so much! That is exactly what I needed. My script is working perfectly now. I will be able to keep track of the number of shots fired with ranged weapons, as well as define options for unlimited ammo. Thank you again.