Jump to content

Recommended Posts

Hello,
Can anyone experienced help me out a little with this piece of code?
It should consider number of bonuses when adding new, but it doesn't. Maybe the function attrcount is wrongly defined?
The define checks if you can add bonus into an item and highlights with red or green.
 

Spoiler

    def __CanAddItemAttr(self, dstSlotPos):
        dstItemVNum = player.GetItemIndex(dstSlotPos)
        if dstItemVNum == 0:
            return False

        item.SelectItem(dstItemVNum)
        
        if not item.GetItemType() in (item.ITEM_TYPE_WEAPON, item.ITEM_TYPE_ARMOR):    
            return False
            
        attrCount = 0
        for i in xrange(player.METIN_SOCKET_MAX_NUM):
            if player.GetItemAttribute(dstSlotPos, i) != 0:
                return True

        if attrCount<4:
            return False

                                
        return False

 

 

Link to comment
Share on other sites

  • Honorable Member

The player.GetItemAttribute([slotWindow=INVENTORY,] slotPos, attrIndex) returns a tuple, don't forget.

		attrCount = 0
		for i in xrange(player.ATTRIBUTE_SLOT_NORM_NUM):
			if player.GetItemAttribute(dstSlotWindow, dstSlotPos, i)[0] != 0:
				attrCount += 1

		if attrCount < 4:
			return True

		return False

 

  • Love 1
Link to comment
Share on other sites

58 minutes ago, xP3NG3Rx said:

The player.GetItemAttribute([slotWindow=INVENTORY,] slotPos, attrIndex) returns a tuple, don't forget.


		attrCount = 0
		for i in xrange(player.ATTRIBUTE_SLOT_NORM_NUM):
			if player.GetItemAttribute(dstSlotWindow, dstSlotPos, i)[0] != 0:
				attrCount += 1

		if attrCount < 4:
			return True

		return False

 

You made new const for it right? Can you point me to how to do that too please?
I would like to make one for normal bonus checking and 6/7 bonus checking.

Link to comment
Share on other sites

Both ITEM_ATTRIBUTE_SLOT_MAX_NUM and ITEM_SOCKET_SLOT_MAX_NUM are in Userinterface/GameType.h,  and can be called as ATTRIBUTE_SLOT_MAX_NUM and METIN_SOCKET_MAX_NUM respectively within python scripts

Spoiler

enum
{
    ITEM_SOCKET_SLOT_MAX_NUM = 3,
    ITEM_ATTRIBUTE_SLOT_MAX_NUM = 7,
};

However sincerly i can't understand your code:
 

  attrCount = 0                                          //here you inizialize the constant
        for i in xrange(player.METIN_SOCKET_MAX_NUM):     // for i in xrange(3):
            if player.GetItemAttribute(dstSlotPos, i) != 0:             // GetItemAttribute: is this a custom function you made or are you using a incomplete type of the void                                                                                     //CPythonPlayer::GetItemAttribute(TItemPos Cell, DWORD dwAttrSlotIndex, BYTE * pbyType, short * psValue)?  if so                                                            //it will check against ITEM_ATTRIBUTE_SLOT_MAX_NUM == 7 (it will return true for 5, 6 and 7th bonuses)
                return True

        if attrCount<4:                                        //here if attrCount is 3, 2, 1 will return false is this intended? maybe attrCount>3
            return False

                                
        return False

Link to comment
Share on other sites

5 hours ago, OtherChoice said:

Both ITEM_ATTRIBUTE_SLOT_MAX_NUM and ITEM_SOCKET_SLOT_MAX_NUM are in Userinterface/GameType.h,  and can be called as ATTRIBUTE_SLOT_MAX_NUM and METIN_SOCKET_MAX_NUM respectively within python scripts

  Reveal hidden contents

enum
{
    ITEM_SOCKET_SLOT_MAX_NUM = 3,
    ITEM_ATTRIBUTE_SLOT_MAX_NUM = 7,
};

However sincerly i can't understand your code:
 

  attrCount = 0                                          //here you inizialize the constant
        for i in xrange(player.METIN_SOCKET_MAX_NUM):     // for i in xrange(3):
            if player.GetItemAttribute(dstSlotPos, i) != 0:             // GetItemAttribute: is this a custom function you made or are you using a incomplete type of the void                                                                                     //CPythonPlayer::GetItemAttribute(TItemPos Cell, DWORD dwAttrSlotIndex, BYTE * pbyType, short * psValue)?  if so                                                            //it will check against ITEM_ATTRIBUTE_SLOT_MAX_NUM == 7 (it will return true for 5, 6 and 7th bonuses)
                return True

        if attrCount<4:                                        //here if attrCount is 3, 2, 1 will return false is this intended? maybe attrCount>3
            return False

                                
        return False

The function was like this when I downloaded the client and so is in every client I tried to look into. It's part of the uiinventory.py where it checks if you can put item to destination item. I didn't edit this script in any way and should be then functional? But it's not. Even though I have a value of true it doesn't seem to work and numbers of attrCount don't change anything. I tried putting there elif with different value and return, still didn't succeed. It behaves like attrCount does nothing.

I guess the function is incomplete as you say.
Also, there should be true in my opinion as well :)

if attrCount<4:
   return True
else:
   return False

Did not work.

Link to comment
Share on other sites

12 minutes ago, ragem0re said:

Please repeat once again, what exactly do you want?

Maybe I can try to help with my limited python skills :ph34r:

My python skills are limited more than yours I bet :D
Anyway.. I want the python script to check correctly if I can add a bonus into an item. When you hover with bonus over an item it should show green or red color, depending on if you can add it or not. The script is not correct, however, because it doesn't do so.

Example: If I have 4 bonuses, it should be red when hovering with normal bonuses over it and green if not, but it's always green.
Also when I have 4 bonuses I would like 5th bonus to show green and when you have 5 bonuses to mark it as red
If 6/7.. you understand me don't you?

Link to comment
Share on other sites

40 minutes ago, Denny2399 said:

The function was like this when I downloaded the client and so is in every client I tried to look into. It's part of the uiinventory.py where it checks if you can put item to destination item. I didn't edit this script in any way and should be then functional? But it's not. Even though I have a value of true it doesn't seem to work and numbers of attrCount don't change anything. I tried putting there elif with different value and return, still didn't succeed. It behaves like attrCount does nothing.

This is the function i have, as you can see the last part is different

Spoiler

def __CanAddItemAttr(self, dstSlotPos):
        dstItemVNum = player.GetItemIndex(dstSlotPos)
        if dstItemVNum == 0:
            return False

        item.SelectItem(dstItemVNum)
        
        if not item.GetItemType() in (item.ITEM_TYPE_WEAPON, item.ITEM_TYPE_ARMOR):     
            return False
            
        attrCount = 0
        for i in xrange(player.METIN_SOCKET_MAX_NUM):
            if player.GetItemAttribute(dstSlotPos, i) != 0:
                attrCount += 1

        if attrCount<4:
            return True                   //THIS RETURNS TRUE if attrcount is 1,2,3 while in yours it will return false
                                
        return False

 

Link to comment
Share on other sites

To be clear: your function __CanAddItemAttr(self, dstSlotPos) has a wrong false 

Spoiler

 if attrCount<4:
            return False

replace with 

 if attrCount<4:
            return True

However this function will return true for bonus 1,2,3,4 and false for 5,6,7 and it is used to check whether  you can add a bonus with reinforce item (vnum 71085).
What was your goal? having reinforce item higlighting the item?

Link to comment
Share on other sites

3 hours ago, OtherChoice said:

To be clear: your function __CanAddItemAttr(self, dstSlotPos) has a wrong false 

  Hide contents

 if attrCount<4:
            return False

replace with 

 if attrCount<4:
            return True

However this function will return true for bonus 1,2,3,4 and false for 5,6,7 and it is used to check whether  you can add a bonus with reinforce item (vnum 71085).
What was your goal? having reinforce item higlighting the item?

I did edit it this way before, then I returned it back how it was:)
I knew there has to be true, but even then it doesn't work how it should.
I had it exactly the way you have it, but something is probably wrong. Anyway just to be sure I will try it again and report you back in a moment.

EDIT: I used your function and the marking is red in every situation, even when I can add the bonus.
Might something be wrong in my source?
I'm using mainline released.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.