Need help understanding GetRarity function

06/20/2020 00:02 Rappy99#1
I'm rewriting a bot and running into some trouble.

Is there a way to know the rarity of an item before picking it up? GetRarity doesn't seem to work on a targeted item on the ground (ModelId and rarity return 0 - oddly, though, type does not).

Speaking of which, is there a reference to what an item's "type" is (as returned from DLLStructGetData($item,"type"))?
06/20/2020 02:12 list comprehension#2
Sure you can filter things out on the ground. Just need to add a filter function. A common one in the bots that are public have a function like this:

Code:
Func CanPickUp($aItem)
   Local $lRarity = GetRarity($aItem)
   
   If $lRarity == $RARITY_PURPLE Then
		Return False
   Else
		 Return True
   EndIf
EndFunc	;==>CanPickUp
Here are some constants for rarity and type:

Code:
;Rarity
Global Const $RARITY_WHITE	= 2621
Global Const $RARITY_GRAY	= 2622
Global Const $RARITY_BLUE	= 2623
Global Const $RARITY_GOLD	= 2624
Global Const $RARITY_PURPLE	= 2626
Global Const $RARITY_GREEN	= 2627
Global Const $RARITY_RED	= 33026

;Type
Global Const $TYPE_SALVAGE				= 0
Global Const $TYPE_LEADHAND				= 1
Global Const $TYPE_AXE					= 2
Global Const $TYPE_BAG					= 3
Global Const $TYPE_BOOTS				= 4
Global Const $TYPE_BOW					= 5
Global Const $TYPE_BUNDLE				= 6
Global Const $TYPE_CHESTPIECE			= 7
Global Const $TYPE_RUNE_AND_MOD			= 8
Global Const $TYPE_USABLE				= 9
Global Const $TYPE_DYE					= 10
Global Const $TYPE_MATERIAL_AND_ZCOINS	= 11
Global Const $TYPE_OFFHAND				= 12
Global Const $TYPE_GLOVES				= 13
Global Const $TYPE_CELESTIAL_SIGIL		= 14
Global Const $TYPE_HAMMER				= 15
Global Const $TYPE_HEADPIECE			= 16
Global Const $TYPE_TROPHY_2				= 17	; SalvageItem / CC Shards?
Global Const $TYPE_KEY					= 18
Global Const $TYPE_LEGGINS				= 19
Global Const $TYPE_GOLD_COINS			= 20
Global Const $TYPE_QUEST_ITEM			= 21
Global Const $TYPE_WAND					= 22
Global Const $TYPE_SHIELD				= 24
Global Const $TYPE_STAFF				= 26
Global Const $TYPE_SWORD				= 27
Global Const $TYPE_KIT					= 29	; + Keg Ale
Global Const $TYPE_TROPHY				= 30
Global Const $TYPE_SCROLL				= 31
Global Const $TYPE_DAGGERS				= 32
Global Const $TYPE_PRESENT				= 33
Global Const $TYPE_MINIPET				= 34
Global Const $TYPE_SCYTHE				= 35
Global Const $TYPE_SPEAR				= 36
Global Const $TYPE_BOOKS				= 43	; Encrypted Charr Battle Plan/Decoder, Golem User Manual, Books
Global Const $TYPE_COSTUME_BODY			= 44
Global Const $TYPE_COSTUME_HEADPICE		= 45
Global Const $TYPE_NOT_EQUIPPED			= 46
06/20/2020 02:23 Rappy99#3
Unfortunately, that looks very similar to what I have, but it's not working for me.

Code:
Global Const $Rarity_Gold   = 2624
Global Const $Rarity_Purple = 2626
Global Const $Rarity_Blue   = 2623
Global Const $Rarity_White  = 2621

CanPickUp(GetCurrentTarget())

Func CanPickUp($lItem)
	If IsDllStruct($lItem) = 0 Then $lItem = GetAgentByID($lItem)

	Local $lModelID = DllStructGetData(($lItem), 'ModelId')
	Local $aExtraID = DllStructGetData($lItem, 'ExtraId')
	Local $lRarity = GetRarity($lItem)
	Local $Requirement = GetItemReq($lItem)

	MsgBox(0,"Stuff",$lModelID & " - " & $aExtraID & " - " & $lRarity & " - " & $Requirement)
EndFunc
I've not been able to get beyond this point because all of those variables return 0.
06/20/2020 12:59 FriendlyFarmer#4
The problem is that you are still working with an agent, and not with an item. It's no surprise that your code doesn't work, since you are trying to extract item info from an agent.
You have to convert (maybe not the right word) the agent into an item first:
Code:
Func CanPickUp($lAgent)
	If IsDllStruct($lAgent) = 0 Then $lAgent = GetAgentByID($lAgent)
	Local $lAgentId = DllStructGetData($lAgent, "Id")
	Local $lItem = GetItemByAgentID($lAgentId)
	.
	.
	.
06/20/2020 22:42 Rappy99#5
Quote:
Originally Posted by FriendlyFarmer View Post
The problem is that you are still working with an agent, and not with an item. It's no surprise that your code doesn't work, since you are trying to extract item info from an agent.
You have to convert (maybe not the right word) the agent into an item first
That was indeed the issue. Thank you very much. I'm still getting used to what functions in GWA2 need to be passed.