예제 #1
0
 def apply(self, pirate):
     gender = localAvatar.style.getGender()
     if gender == 'm':
         idx = ItemGlobals.getMaleModelId(self.uid)
     else:
         idx = ItemGlobals.getFemaleModelId(self.uid)
     primaryColor = ItemGlobals.getPrimaryColor(self.uid)
     secondaryColor = ItemGlobals.getSecondaryColor(self.uid)
     if self.jewelryType == JewelryGlobals.LBROW:
         pirate.setJewelryZone3(idx, primaryColor, secondaryColor)
     elif self.jewelryType == JewelryGlobals.RBROW:
         pirate.setJewelryZone4(idx, primaryColor, secondaryColor)
     elif self.jewelryType == JewelryGlobals.LEAR:
         pirate.setJewelryZone1(idx, primaryColor, secondaryColor)
     elif self.jewelryType == JewelryGlobals.REAR:
         pirate.setJewelryZone2(idx, primaryColor, secondaryColor)
     elif self.jewelryType == JewelryGlobals.NOSE:
         pirate.setJewelryZone5(idx, primaryColor, secondaryColor)
     elif self.jewelryType == JewelryGlobals.MOUTH:
         pirate.setJewelryZone6(idx, primaryColor, secondaryColor)
     elif self.jewelryType == JewelryGlobals.LHAND:
         pirate.setJewelryZone7(idx, primaryColor, secondaryColor)
     elif self.jewelryType == JewelryGlobals.RHAND:
         pirate.setJewelryZone8(idx, primaryColor, secondaryColor)
     
     pirate.model.handleJewelryHiding()
 def addTab(self, itemGroup, item):
     newTab = self.tabBar.addTab(itemGroup, command = self.setPage, extraArgs = [
         itemGroup])
     repId = WeaponGlobals.getRepId(item)
     if repId:
         iconName = ReputationGlobals.RepIcons.get(repId)
         if repId == InventoryType.FishingRep:
             icon = StoreGUI.FishingIcons.find('**/%s' % iconName)
         else:
             icon = StoreGUI.WeaponIcons.find('**/%s' % iconName)
     elif InventoryType.begin_Consumables <= item:
         pass
     elif repId or ItemGlobals.getClass(item) == InventoryType.ItemTypeConsumable:
         iconName = EconomyGlobals.getItemIcons(item)
         icon = StoreGUI.SkillIcons.find('**/%s' % iconName)
     elif InventoryType.begin_WeaponCannonAmmo <= item:
         pass
     elif ItemGlobals.getClass(item) == InventoryType.ItemTypeConsumable:
         iconName = EconomyGlobals.getItemIcons(InventoryType.CannonL1)
         icon = StoreGUI.WeaponIcons.find('**/%s' % iconName)
     elif InventoryType.begin_WeaponGrenadeAmmo <= item:
         pass
     elif ItemGlobals.getClass(item) == InventoryType.ItemTypeConsumable:
         itemId = InventoryType.GrenadeWeaponL1
         iconName = EconomyGlobals.getItemIcons(itemId)
         icon = StoreGUI.WeaponIcons.find('**/%s' % iconName)
     elif InventoryType.begin_FishingLures <= item:
         pass
     elif ItemGlobals.getClass(item) == InventoryType.ItemTypeConsumable:
         icon = StoreGUI.FishingIcons.find('**/pir_t_gui_gen_fish_lure')
     else:
         icon = None
     newTab.nameTag = DirectLabel(parent = newTab, relief = None, state = DGG.DISABLED, image = icon, image_scale = 0.40000000000000002, image_pos = (0, 0, 0.040000000000000001), pos = (0.059999999999999998, 0, -0.035000000000000003))
     self.pageNames.append(itemGroup)
예제 #3
0
    def getItemRequirements(self, itemType, otherAdds=[]):
        if not itemType:
            return
        results = {}
        if game.process == 'client':
            paidStatus = Freebooter.getPaidStatus(self.ownerId)
        else:
            paidStatus = Freebooter.getPaidStatusAI(self.ownerId)
        rarity = ItemGlobals.getRarity(itemType)
        if rarity != ItemConstants.CRUDE:
            if not paidStatus:
                results['paidStatus'] = (
                 rarity != ItemConstants.CRUDE, False)
            itemClass = ItemGlobals.getClass(itemType)
            itemRepId = (itemClass == InventoryType.ItemTypeWeapon or itemClass == InventoryType.ItemTypeCharm) and ItemGlobals.getItemRepId(itemType)
            itemRep = self.getReputation(itemRepId)
            itemLevel = ReputationGlobals.getLevelFromTotalReputation(itemRepId, itemRep)[0]
            weaponReq = ItemGlobals.getWeaponRequirement(itemType)
            trainingToken = EconomyGlobals.getItemTrainingReq(itemType)
            trainingAmt = self.getItemQuantity(trainingToken)
            for currAdd in otherAdds:
                otherAdd = InvItem(currAdd)
                if otherAdd.getCat() == trainingToken:
                    otherAdd.getCount() > 0 and trainingAmt += otherAdd.getCount()

            weaponLevelPass = weaponReq == None or itemLevel >= weaponReq
            weaponTrainPass = trainingToken == 0 or trainingToken == None or trainingAmt > 0
            results['itemLevel'] = (weaponReq, weaponLevelPass and weaponTrainPass)
        else:
            results['itemLevel'] = (
             0, True)
        return results
예제 #4
0
 def loadData(self):
     itemId = self.data[0]
     item, quantity = self.data
     self.quantity = quantity
     itemType = EconomyGlobals.getItemType(itemId)
     if itemType <= ItemType.WAND:
         itemTypeName = PLocalizer.getItemSubtypeName(
             ItemGlobals.getSubtype(itemId))
     else:
         itemTypeName = PLocalizer.InventoryItemClassNames.get(itemType)
     if itemType <= ItemType.WAND or itemType == ItemType.POTION:
         name = PLocalizer.getItemName(itemId)
         self.price = ItemGlobals.getGoldCost(itemId)
     else:
         name = PLocalizer.InventoryTypeNames.get(item)
         self.price = EconomyGlobals.getItemCost(item)
     if self.sell:
         self.price /= 2
     if self.buy:
         if itemType > ItemType.WAND:
             if itemType != ItemType.POTION:
                 self.quantity = EconomyGlobals.getItemQuantity(itemId)
             self.price *= self.quantity
             self.price = int(self.price)
         self.name = PLocalizer.makeHeadingString(name, 2)
         self.itemType = itemTypeName
         if itemType != ItemType.FISHING_LURE:
             self.minLvl = itemType != ItemType.POTION and ItemGlobals.getWeaponRequirement(
                 itemId)
         else:
             self.minLvl = 0
     else:
         self.minLvl = EconomyGlobals.getItemMinLevel(self.data[0])
예제 #5
0
def getEquipRanges(itemCat, itemType, expanded=False):
    if itemCat == InventoryType.ItemTypeClothing:
        if itemType:
            equipType = ItemGlobals.getType(itemType)
            ranges = Locations.LOCATION_EQUIP_RANGES_CLOTHING.get(equipType)
        else:
            ranges = (Locations.RANGE_EQUIP_CLOTHES, )
    elif itemCat == InventoryType.ItemTypeJewelry:
        if itemType:
            equipType = ItemGlobals.getType(itemType)
            ranges = Locations.LOCATION_EQUIP_RANGES_JEWELRY.get(equipType)
        else:
            ranges = (Locations.RANGE_EQUIP_JEWELRY, )
    elif itemCat == InventoryType.ItemTypeTattoo:
        if itemType:
            equipType = ItemGlobals.getType(itemType)
            ranges = Locations.LOCATION_EQUIP_RANGES_TATTOO.get(equipType)
        else:
            ranges = (Locations.RANGE_EQUIP_TATTOO, )
    elif itemCat == InventoryType.ItemTypeWeapon:
        ranges = (Locations.RANGE_EQUIP_WEAPONS, )
    elif itemCat == InventoryType.ItemTypeCharm:
        ranges = (Locations.RANGE_EQUIP_ITEMS, )
    else:
        return None
    if expanded:
        ranges = expandRanges(ranges)

    return ranges
예제 #6
0
def getEquipRanges(itemCat, itemType, expanded = False):
    if itemCat == InventoryType.ItemTypeClothing:
        if itemType:
            equipType = ItemGlobals.getType(itemType)
            ranges = Locations.LOCATION_EQUIP_RANGES_CLOTHING.get(equipType)
        else:
            ranges = (Locations.RANGE_EQUIP_CLOTHES,)
    elif itemCat == InventoryType.ItemTypeJewelry:
        if itemType:
            equipType = ItemGlobals.getType(itemType)
            ranges = Locations.LOCATION_EQUIP_RANGES_JEWELRY.get(equipType)
        else:
            ranges = (Locations.RANGE_EQUIP_JEWELRY,)
    elif itemCat == InventoryType.ItemTypeTattoo:
        if itemType:
            equipType = ItemGlobals.getType(itemType)
            ranges = Locations.LOCATION_EQUIP_RANGES_TATTOO.get(equipType)
        else:
            ranges = (Locations.RANGE_EQUIP_TATTOO,)
    elif itemCat == InventoryType.ItemTypeWeapon:
        ranges = (Locations.RANGE_EQUIP_WEAPONS,)
    elif itemCat == InventoryType.ItemTypeCharm:
        ranges = (Locations.RANGE_EQUIP_ITEMS,)
    else:
        return None
    if expanded:
        ranges = expandRanges(ranges)
    
    return ranges
예제 #7
0
 def apply(self, pirate):
     gender = localAvatar.style.getGender()
     if gender == 'm':
         idx = ItemGlobals.getMaleModelId(self.uid)
     else:
         idx = ItemGlobals.getFemaleModelId(self.uid)
     primaryColor = ItemGlobals.getPrimaryColor(self.uid)
     secondaryColor = ItemGlobals.getSecondaryColor(self.uid)
     if self.jewelryType == JewelryGlobals.LBROW:
         pirate.setJewelryZone3(idx, primaryColor, secondaryColor)
     elif self.jewelryType == JewelryGlobals.RBROW:
         pirate.setJewelryZone4(idx, primaryColor, secondaryColor)
     elif self.jewelryType == JewelryGlobals.LEAR:
         pirate.setJewelryZone1(idx, primaryColor, secondaryColor)
     elif self.jewelryType == JewelryGlobals.REAR:
         pirate.setJewelryZone2(idx, primaryColor, secondaryColor)
     elif self.jewelryType == JewelryGlobals.NOSE:
         pirate.setJewelryZone5(idx, primaryColor, secondaryColor)
     elif self.jewelryType == JewelryGlobals.MOUTH:
         pirate.setJewelryZone6(idx, primaryColor, secondaryColor)
     elif self.jewelryType == JewelryGlobals.LHAND:
         pirate.setJewelryZone7(idx, primaryColor, secondaryColor)
     elif self.jewelryType == JewelryGlobals.RHAND:
         pirate.setJewelryZone8(idx, primaryColor, secondaryColor)
     pirate.model.handleJewelryHiding()
 def loadData(self):
     itemId = self.data[0]
     (item, quantity) = self.data
     self.quantity = quantity
     itemType = EconomyGlobals.getItemType(itemId)
     if itemType <= ItemType.WAND:
         itemTypeName = PLocalizer.getItemSubtypeName(ItemGlobals.getSubtype(itemId))
     else:
         itemTypeName = PLocalizer.InventoryItemClassNames.get(itemType)
     if itemType <= ItemType.WAND or itemType == ItemType.POTION:
         name = PLocalizer.getItemName(itemId)
         self.price = ItemGlobals.getGoldCost(itemId)
     else:
         name = PLocalizer.InventoryTypeNames.get(item)
         self.price = EconomyGlobals.getItemCost(item)
     if self.sell:
         self.price /= 2
     
     if self.buy:
         if itemType > ItemType.WAND and itemType != ItemType.POTION:
             self.quantity = EconomyGlobals.getItemQuantity(itemId)
         
         self.price *= self.quantity
         self.price = int(self.price)
     
     self.name = PLocalizer.makeHeadingString(name, 2)
     self.itemType = itemTypeName
     if itemType != ItemType.FISHING_LURE:
         if itemType != ItemType.POTION:
             self.minLvl = ItemGlobals.getWeaponRequirement(itemId)
         else:
             self.minLvl = 0
     else:
         self.minLvl = EconomyGlobals.getItemMinLevel(self.data[0])
    def __init__(self, manager, itemTuple, imageScaleFactor = 1.0):
        InventoryUIItem.InventoryUIItem.__init__(self, manager, itemTuple, imageScaleFactor = imageScaleFactor)
        charmIcons = loader.loadModel('models/gui/gui_icons_inventory')
        itemType = ItemGlobals.getType(itemTuple[1])
        if ItemGlobals.getIcon(itemTuple[1]):
            self['image'] = charmIcons.find('**/%s' % ItemGlobals.getIcon(itemTuple[1]))

        self['image_scale'] = 0.10000000000000001 * imageScaleFactor
        self.helpFrame = None
        self.cm = CardMaker('itemCard')
        self.cm.setFrame(-0.29999999999999999, 0.29999999999999999, -0.089999999999999997, 0.089999999999999997)
        self.buffer = None
        self.lens = PerspectiveLens()
        self.lens.setNear(0.10000000000000001)
        self.lens.setAspectRatio(0.59999999999999998 / 0.17999999999999999)
        self.realItem = None
        self.itemCard = None
        self.portraitSceneGraph = NodePath('PortraitSceneGraph')
        detailGui = loader.loadModel('models/gui/gui_card_detail')
        self.bg = detailGui.find('**/color')
        self.bg.setScale(4)
        self.bg.setPos(0, 17, -6.2999999999999998)
        self.glow = detailGui.find('**/glow')
        self.glow.setScale(3)
        self.glow.setPos(0, 17, -6.2999999999999998)
        self.glow.setColor(1, 1, 1, 0.80000000000000004)
        self.setBin('gui-fixed', 1)
        self.accept('open_main_window', self.createBuffer)
        self.accept('aspectRatioChanged', self.createBuffer)
        self.accept('close_main_window', self.destroyBuffer)
 def cmp(item1, item2):
     goldCost1 = ItemGlobals.getGoldCost(item1[1])
     if not goldCost1:
         goldCost1 = item1[1]
     goldCost2 = ItemGlobals.getGoldCost(item2[1])
     if not goldCost2:
         goldCost2 = item2[1]
     return int(goldCost2 - goldCost1)
예제 #11
0
 def __init__(self, uid):
     self.itemClass = ItemGlobals.getClass(uid)
     self.itemType = ItemGlobals.getType(uid)
     self.cost = ItemGlobals.getGoldCost(uid)
     SimpleItem.__init__(self, uid)
     self.holidayId = ItemGlobals.getHoliday(uid)
     if self.Icons:
         self.icon = self.Icons.find('**/%s' % ItemGlobals.getIcon(uid))
예제 #12
0
 def checkInfamyReq(self, itemId):
     landInfamyLevel = ItemGlobals.getLandInfamyRequirement(itemId)
     seaInfamyLevel = ItemGlobals.getSeaInfamyRequirement(itemId)
     if landInfamyLevel and TitleGlobals.getRank(TitleGlobals.LandPVPTitle, localAvatar.getInfamyLand()) < landInfamyLevel:
         self.highlightRed(PLocalizer.LandInfamyRequirement % landInfamyLevel)
     
     if seaInfamyLevel and TitleGlobals.getRank(TitleGlobals.ShipPVPTitle, localAvatar.getInfamySea()) < seaInfamyLevel:
         self.highlightRed(PLocalizer.SeaInfamyRequirement % seaInfamyLevel)
예제 #13
0
 def __init__(self, uid):
     self.itemClass = ItemGlobals.getClass(uid)
     self.itemType = ItemGlobals.getType(uid)
     self.cost = ItemGlobals.getGoldCost(uid)
     SimpleItem.__init__(self, uid)
     self.holidayId = ItemGlobals.getHoliday(uid)
     if self.Icons:
         self.icon = self.Icons.find('**/%s' % ItemGlobals.getIcon(uid))
        def cmp(item1, item2):
            goldCost1 = ItemGlobals.getGoldCost(item1[1])
            if not goldCost1:
                goldCost1 = item1[1]

            goldCost2 = ItemGlobals.getGoldCost(item2[1])
            if not goldCost2:
                goldCost2 = item2[1]

            return int(goldCost2 - goldCost1)
예제 #15
0
 def getGeomParams(itemId):
     geomParams = { }
     itemType = EconomyGlobals.getItemType(itemId)
     if itemType <= ItemType.WAND or itemType == ItemType.POTION:
         if itemType == ItemType.POTION:
             geomParams['geom'] = InventoryItemGui.skillIcons.find('**/%s' % ItemGlobals.getIcon(itemId))
         else:
             itemType = ItemGlobals.getType(itemId)
             if ItemGlobals.getIcon(itemId):
                 geomParams['geom'] = InventoryItemGui.weaponIcons.find('**/%s' % ItemGlobals.getIcon(itemId))
             
         geomParams['geom_scale'] = 0.11
         geomParams['geom_pos'] = (0.080000000000000002, 0, 0.068000000000000005)
     else:
         itemClass = EconomyGlobals.getItemCategory(itemId)
         itemType = EconomyGlobals.getItemType(itemId)
         if itemType == ItemType.FISHING_ROD or itemType == ItemType.FISHING_LURE:
             asset = EconomyGlobals.getItemIcons(itemId)
             if asset:
                 geomParams['geom'] = InventoryItemGui.fishingIcons.find('**/%s*' % asset)
                 geomParams['geom_scale'] = 0.11
                 geomParams['geom_pos'] = (0.080000000000000002, 0, 0.068000000000000005)
             
         elif itemClass == ItemType.WEAPON and itemClass == ItemType.POUCH or itemClass == ItemType.AMMO:
             asset = EconomyGlobals.getItemIcons(itemId)
             if asset:
                 geomParams['geom'] = InventoryItemGui.weaponIcons.find('**/%s*' % asset)
                 geomParams['geom_scale'] = 0.11
                 geomParams['geom_pos'] = (0.080000000000000002, 0, 0.068000000000000005)
             
         elif itemClass == ItemType.CONSUMABLE:
             asset = EconomyGlobals.getItemIcons(itemId)
             if asset:
                 geomParams['geom'] = InventoryItemGui.skillIcons.find('**/%s*' % asset)
                 geomParams['geom_scale'] = 0.11
                 geomParams['geom_pos'] = (0.080000000000000002, 0, 0.068000000000000005)
             
         
     if not InventoryType.begin_WeaponCannonAmmo <= itemId or itemId <= InventoryType.end_WeaponCannonAmmo:
         if (InventoryType.begin_WeaponPistolAmmo <= itemId or itemId <= InventoryType.end_WeaponGrenadeAmmo or InventoryType.begin_WeaponDaggerAmmo <= itemId) and itemId <= InventoryType.end_WeaponDaggerAmmo:
             skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId)
             if skillId:
                 asset = WeaponGlobals.getSkillIcon(skillId)
                 if asset:
                     geomParams['geom'] = InventoryListItem.skillIcons.find('**/%s' % asset)
                     geomParams['geom_scale'] = 0.14999999999999999
                     geomParams['geom_pos'] = (0.069000000000000006, 0, 0.069000000000000006)
                 
             
         elif InventoryType.SmallBottle <= itemId and itemId <= InventoryType.LargeBottle:
             geomParams['geom'] = InventoryListItem.topGui.find('**/main_gui_ship_bottle')
             geomParams['geom_scale'] = 0.10000000000000001
             geomParams['geom_pos'] = (0.069000000000000006, 0, 0.069000000000000006)
         
     return geomParams
예제 #16
0
    def __runSelfTest_limits(self, itemCatFilter, verbose):
        itemIds = ItemGlobals.getAllItemIds()
        for currItemId in itemIds:
            if itemCatFilter != None:
                if itemCatFilter != ItemGlobals.getClass(currItemId):
                    continue
                itemIds = ItemGlobals.getAllConsumableIds()
                itemLimit = ItemGlobals.getStackLimit(currItemId)
                itemCat = ItemGlobals.getClass(currItemId)
                quantity = self.getItemQuantity(itemCat, currItemId)
                if isStackableType(itemCat):
                    pass
                print verbose and 'item limit for item %s:%s passed (quantity: %s limit:%s)' % (itemCat, currItemId, quantity, itemLimit or 1)

        return
예제 #17
0
def getItemLimit(category, type=None):
    if category == InventoryType.ItemTypeMoney or category == InventoryType.ItemTypeMoneyWagered:
        return GOLD_CAP
    elif itemStoresLocation(category) and type:
        return ItemGlobals.getStackLimit(type)
    else:
        return None
    def avIsReady(self, av):
        Locations = Locations
        import pirates.inventory.InventoryGlobals
        inv = av.getInventory()
        if not inv:
            return False

        categoryId = ItemGlobals.getClass(self.itemId)
        if inv.getItemQuantity(categoryId, self.itemId) > 0:
            if categoryId == InventoryType.ItemTypeWeapon:
                if av.currentWeaponId == itemId:
                    return True
                else:
                    return False
            elif categoryId == InventoryType.ItemTypeCharm:
                if av.getCurrentCharm() == self.itemId:
                    return True
                else:
                    return False
            elif categoryId == InventoryType.ItemTypeClothing:
                locationRange = Locations.RANGE_EQUIP_CLOTHES
            elif categoryId == InventoryType.ItemTypeJewelry:
                locationRange = Locations.RANGE_EQUIP_JEWELRY
            elif categoryId == InventoryType.ItemTypeTattoo:
                locationRange = Locations.RANGE_EQUIP_TATTOO
            else:
                locationRange = (0, 0)
            for location in range(locationRange[0], locationRange[1] + 1):
                locatable = inv.getLocatables().get(location)
                if locatable and locatable[1] == self.itemId:
                    return True
                    continue


        return False
 def __init__(self, manager, itemTuple, imageScaleFactor = 1.0, showMax = 1):
     InventoryUIStackItem.InventoryUIStackItem.__init__(self, manager, itemTuple, imageScaleFactor = imageScaleFactor, showMax = showMax, update = False)
     self.initialiseoptions(InventoryUIConsumableItem)
     skillIcons = loader.loadModel('models/textureCards/skillIcons')
     self['image'] = skillIcons.find('**/%s' % ItemGlobals.getIcon(self.itemTuple[1]))
     self['image_scale'] = 0.10000000000000001 * imageScaleFactor
     self.helpFrame = None
     self.hasDrunk = False
     self.cm = CardMaker('itemCard')
     self.cm.setFrame(-0.29999999999999999, 0.29999999999999999, -0.089999999999999997, 0.089999999999999997)
     self.buffer = None
     self.lens = PerspectiveLens()
     self.lens.setNear(0.10000000000000001)
     self.lens.setAspectRatio(0.59999999999999998 / 0.17999999999999999)
     self.realItem = None
     self.iconLabel = None
     self.itemCard = None
     self.portraitSceneGraph = NodePath('PortraitSceneGraph')
     detailGui = loader.loadModel('models/gui/gui_card_detail')
     self.bg = detailGui.find('**/color')
     self.bg.setScale(4)
     self.bg.setPos(0, 17, -6.2999999999999998)
     self.glow = detailGui.find('**/glow')
     self.glow.setScale(3)
     self.glow.setPos(0, 17, -6.2999999999999998)
     self.glow.setColor(1, 1, 1, 0.80000000000000004)
     self.setBin('gui-fixed', 1)
     self.accept('open_main_window', self.createBuffer)
     self.accept('aspectRatioChanged', self.createBuffer)
     self.accept('close_main_window', self.destroyBuffer)
예제 #20
0
 def getName(self):
     itemTypeName = PLocalizer.getItemName(self.getId())
     clothingName = PLocalizer.TailorColorStrings.get(self.getColorId())
     if ItemGlobals.canDyeItem(self.getId()):
         return clothingName + ' ' + itemTypeName
     else:
         return itemTypeName
예제 #21
0
    def playOuch(
        self,
        skillId,
        ammoSkillId,
        targetEffects,
        attacker,
        pos,
        itemEffects=[],
        multihit=0,
        targetBonus=0,
        skillResult=0,
    ):
        if self.isDisabled():
            return None

        if (
            hasattr(attacker, "currentWeaponId")
            and ItemGlobals.getWeaponAttributes(attacker.currentWeaponId, ItemGlobals.ANTI_VOODOO_ZOMBIE)
            and self.avatarType.isA(AvatarTypes.VoodooZombie)
        ):
            self.doAntiEffect()

        DistributedBattleNPC.DistributedBattleNPC.playOuch(
            self,
            skillId,
            ammoSkillId,
            targetEffects,
            attacker,
            pos,
            multihit=multihit,
            targetBonus=targetBonus,
            skillResult=skillResult,
        )
 def verifyCombo(self, avId, weaponId, skillId, timestamp):
     if skillId in self.EXCLUDED_SKILLS:
         return 0
     
     combo = self.timers.get(avId)
     if not combo:
         return 0
     
     comboLength = len(combo)
     lastEntry = combo[comboLength - 1]
     lastSkillId = lastEntry[self.SKILLID_INDEX]
     lastTimestamp = lastEntry[self.TIMESTAMP_INDEX]
     subtypeId = ItemGlobals.getSubtype(weaponId)
     if not subtypeId:
         return 0
     
     comboChain = self.COMBO_ORDER.get(subtypeId)
     if not comboChain:
         return 0
     
     repId = WeaponGlobals.getSkillReputationCategoryId(skillId)
     if not repId:
         return 0
     
     if skillId in comboChain:
         index = comboChain.index(skillId)
         requisiteAttack = comboChain[index - 1]
         currentAttack = comboChain[index]
         if lastSkillId != requisiteAttack and lastSkillId != currentAttack and lastSkillId not in self.SPECIAL_SKILLS.get(repId, []):
             return 0
         
     
     return 1
예제 #23
0
 def __init__(self, uid):
     SimpleItem.__init__(self, uid)
     self.itemClass = EconomyGlobals.getItemCategory(uid)
     self.itemType = EconomyGlobals.getItemType(uid)
     self.cost = EconomyGlobals.getItemCost(uid)
     if not self.cost:
         self.cost = ItemGlobals.getGoldCost(uid)
 def getBlurColor(self):
     colorId = ItemGlobals.getVfxType1(self.itemId)
     motion_trail_color = self.motion_color.get(colorId)
     if not motion_trail_color:
         motion_trail_color = self.motion_color.get(ItemGlobals.MotionBlurDefault)
     
     return motion_trail_color[2]
    def playOuch(self,
                 skillId,
                 ammoSkillId,
                 targetEffects,
                 attacker,
                 pos,
                 itemEffects=[],
                 multihit=0,
                 targetBonus=0,
                 skillResult=0):
        if self.isDisabled():
            return None

        if hasattr(attacker,
                   'currentWeaponId') and ItemGlobals.getWeaponAttributes(
                       attacker.currentWeaponId,
                       ItemGlobals.ANTI_VOODOO_ZOMBIE) and self.avatarType.isA(
                           AvatarTypes.VoodooZombie):
            self.doAntiEffect()

        DistributedBattleNPC.DistributedBattleNPC.playOuch(
            self,
            skillId,
            ammoSkillId,
            targetEffects,
            attacker,
            pos,
            multihit=multihit,
            targetBonus=targetBonus,
            skillResult=skillResult)
예제 #26
0
 def jump(self):
     self.fsmLock.acquire()
     try:
         animInfo = ItemGlobals.getJumpAnimInfo(self.av.getCurrentWeapon())
         if self.state == 'Idle':
             startFrame = animInfo[1]
             endFrame = animInfo[3]
             if self.idleJumpIval:
                 self.idleJumpIval.finish()
             self.idleJumpIval = self.av.actorInterval(
                 animInfo[0],
                 startFrame=startFrame,
                 endFrame=endFrame,
                 playRate=1.5,
                 blendInT=0.0,
                 blendOutT=self.BLENDAMT * 0.5)
             self.idleJumpIval.start()
         else:
             startFrame = animInfo[2]
             endFrame = animInfo[3]
             self.av.play(animInfo[0],
                          fromFrame=startFrame,
                          toFrame=endFrame,
                          blendInT=self.BLENDAMT * 0.5,
                          blendOutT=self.BLENDAMT * 0.5)
     finally:
         self.fsmLock.release()
예제 #27
0
 def __init__(self, manager, itemTuple, imageScaleFactor=1.0):
     InventoryUIItem.InventoryUIItem.__init__(
         self, manager, itemTuple, imageScaleFactor=imageScaleFactor)
     weaponIcons = loader.loadModel('models/gui/gui_icons_weapon')
     self['image'] = weaponIcons.find('**/%s' %
                                      ItemGlobals.getIcon(itemTuple[1]))
     self['image_scale'] = 0.10000000000000001 * imageScaleFactor
     self.helpFrame = None
     self.cm = CardMaker('itemCard')
     self.cm.setFrame(-0.29999999999999999, 0.29999999999999999,
                      -0.089999999999999997, 0.089999999999999997)
     self.buffer = None
     self.lens = PerspectiveLens()
     self.lens.setNear(0.5)
     self.lens.setAspectRatio(0.59999999999999998 / 0.17999999999999999)
     self.realItem = None
     self.itemCard = None
     self.portraitSceneGraph = NodePath('PortraitSceneGraph')
     detailGui = loader.loadModel('models/gui/gui_card_detail')
     self.bg = detailGui.find('**/color')
     self.bg.setScale(4)
     self.bg.setPos(0, 17, -6.2999999999999998)
     self.glow = detailGui.find('**/glow')
     self.glow.setScale(3)
     self.glow.setPos(0, 17, -6.2999999999999998)
     self.glow.setColor(1, 1, 1, 0.80000000000000004)
     self.setBin('gui-fixed', 1)
     self.accept('open_main_window', self.createBuffer)
     self.accept('aspectRatioChanged', self.createBuffer)
     self.accept('close_main_window', self.destroyBuffer)
예제 #28
0
    def avIsReady(self, av):
        from pirates.inventory.InventoryGlobals import Locations
        inv = av.getInventory()
        if not inv:
            return False
        categoryId = ItemGlobals.getClass(self.itemId)
        if inv.getItemQuantity(categoryId, self.itemId) > 0:
            if categoryId == InventoryType.ItemTypeWeapon:
                if av.currentWeaponId == itemId:
                    return True
                else:
                    return False
            else:
                if categoryId == InventoryType.ItemTypeCharm:
                    if av.getCurrentCharm() == self.itemId:
                        return True
                    else:
                        return False
                else:
                    if categoryId == InventoryType.ItemTypeClothing:
                        locationRange = Locations.RANGE_EQUIP_CLOTHES
                    else:
                        if categoryId == InventoryType.ItemTypeJewelry:
                            locationRange = Locations.RANGE_EQUIP_JEWELRY
                        else:
                            if categoryId == InventoryType.ItemTypeTattoo:
                                locationRange = Locations.RANGE_EQUIP_TATTOO
                            else:
                                locationRange = (0, 0)
            for location in range(locationRange[0], locationRange[1] + 1):
                locatable = inv.getLocatables().get(location)
                if locatable:
                    return locatable[1] == self.itemId and True

        return False
 def __init__(self, manager, itemTuple, imageScaleFactor = 1.0, showMax = 1):
     InventoryUIStackItem.InventoryUIStackItem.__init__(self, manager, itemTuple, imageScaleFactor = imageScaleFactor, showMax = showMax, update = False)
     self.initialiseoptions(InventoryUIConsumableItem)
     skillIcons = loader.loadModel('models/textureCards/skillIcons')
     self['image'] = skillIcons.find('**/%s' % ItemGlobals.getIcon(self.itemTuple[1]))
     self['image_scale'] = 0.10000000000000001 * imageScaleFactor
     self.helpFrame = None
     self.hasDrunk = False
     self.cm = CardMaker('itemCard')
     self.cm.setFrame(-0.29999999999999999, 0.29999999999999999, -0.089999999999999997, 0.089999999999999997)
     self.buffer = None
     self.lens = PerspectiveLens()
     self.lens.setNear(0.10000000000000001)
     self.lens.setAspectRatio(0.59999999999999998 / 0.17999999999999999)
     self.realItem = None
     self.iconLabel = None
     self.itemCard = None
     self.portraitSceneGraph = NodePath('PortraitSceneGraph')
     detailGui = loader.loadModel('models/gui/gui_card_detail')
     self.bg = detailGui.find('**/color')
     self.bg.setScale(4)
     self.bg.setPos(0, 17, -6.2999999999999998)
     self.glow = detailGui.find('**/glow')
     self.glow.setScale(3)
     self.glow.setPos(0, 17, -6.2999999999999998)
     self.glow.setColor(1, 1, 1, 0.80000000000000004)
     self.setBin('gui-fixed', 1)
     self.accept('open_main_window', self.createBuffer)
     self.accept('aspectRatioChanged', self.createBuffer)
     self.accept('close_main_window', self.destroyBuffer)
예제 #30
0
def getItemLimit(category, type = None):
    if category == InventoryType.ItemTypeMoney or category == InventoryType.ItemTypeMoneyWagered:
        return GOLD_CAP
    elif itemStoresLocation(category) and type:
        return ItemGlobals.getStackLimit(type)
    else:
        return None
 def getName(self):
     itemTypeName = PLocalizer.getItemName(self.getId())
     clothingName = PLocalizer.TailorColorStrings.get(self.getColorId())
     if ItemGlobals.canDyeItem(self.getId()):
         return clothingName + ' ' + itemTypeName
     else:
         return itemTypeName
예제 #32
0
 def getBlurColor(self):
     colorId = ItemGlobals.getVfxType1(self.itemId)
     motion_trail_color = self.motion_color.get(colorId)
     if not motion_trail_color:
         motion_trail_color = self.motion_color.get(
             ItemGlobals.MotionBlurDefault)
     return motion_trail_color[2]
예제 #33
0
    def verifyCombo(self, avId, weaponId, skillId, timestamp):
        if skillId in self.EXCLUDED_SKILLS:
            return 0

        combo = self.timers.get(avId)
        if not combo:
            return 0

        comboLength = len(combo)
        lastEntry = combo[comboLength - 1]
        lastSkillId = lastEntry[self.SKILLID_INDEX]
        lastTimestamp = lastEntry[self.TIMESTAMP_INDEX]
        subtypeId = ItemGlobals.getSubtype(weaponId)
        if not subtypeId:
            return 0

        comboChain = self.COMBO_ORDER.get(subtypeId)
        if not comboChain:
            return 0

        repId = WeaponGlobals.getSkillReputationCategoryId(skillId)
        if not repId:
            return 0

        if skillId in comboChain:
            index = comboChain.index(skillId)
            requisiteAttack = comboChain[index - 1]
            currentAttack = comboChain[index]
            if lastSkillId != requisiteAttack and lastSkillId != currentAttack and lastSkillId not in self.SPECIAL_SKILLS.get(
                    repId, []):
                return 0

        return 1
예제 #34
0
 def loadModel(self):
     self.prop = self.getModel(self.itemId)
     if ItemGlobals.getSubtype(self.itemId) == ItemGlobals.MUSKET:
         bayonetPart = self.prop.find('**/bayonet')
         if bayonetPart:
             bayonetPart.stash()
     self.prop.reparentTo(self)
예제 #35
0
 def getEffectColor(self, itemId = None):
     if not itemId:
         itemId = self.itemId
     
     effectId = ItemGlobals.getVfxType1(itemId)
     color = self.effectTypeInfo.get(effectId)
     return color
예제 #36
0
 def __init__(self, uid):
     SimpleItem.__init__(self, uid)
     self.itemClass = EconomyGlobals.getItemCategory(uid)
     self.itemType = EconomyGlobals.getItemType(uid)
     self.cost = EconomyGlobals.getItemCost(uid)
     if not self.cost:
         self.cost = ItemGlobals.getGoldCost(uid)
예제 #37
0
 def updateItemId(self, itemId):
     if self.itemId == itemId:
         return
     self.itemId = itemId
     self.modelId = ItemGlobals.getModel(itemId)
     if hasattr(self, 'prop'):
         self.prop.removeNode()
         self.loadModel()
예제 #38
0
 def calculateTotalGoldValue(self):
     totalCost = 0
     for cell in self.gridDict.values():
         if cell.inventoryItem:
             totalCost += ItemGlobals.getGoldCost(cell.inventoryItem.getId()) * cell.inventoryItem.amount
             
     
     return totalCost
 def __init__(self, manager, itemTuple, imageScaleFactor=1.0):
     InventoryUIItem.InventoryUIItem.__init__(
         self, manager, itemTuple, imageScaleFactor=imageScaleFactor)
     self.initialiseoptions(InventoryUIClothingItem)
     self['relief'] = None
     tailorGui = loader.loadModel('models/gui/gui_icons_clothing')
     iconName = ItemGlobals.getIcon(itemTuple[1])
     self['image'] = tailorGui.find('**/%s' % iconName)
     self['image_scale'] = 0.10000000000000001 * imageScaleFactor
     iconColorIndex = ItemGlobals.getColor(itemTuple[1])
     dyeColor = itemTuple[3]
     if dyeColor:
         self.iconColor = (DYE_COLORS[dyeColor][0], DYE_COLORS[dyeColor][1],
                           DYE_COLORS[dyeColor][2], 1.0)
     else:
         self.iconColor = (ItemConstants.COLOR_VALUES[iconColorIndex][0],
                           ItemConstants.COLOR_VALUES[iconColorIndex][1],
                           ItemConstants.COLOR_VALUES[iconColorIndex][2],
                           1.0)
     self['image_color'] = (self.iconColor[0], self.iconColor[1],
                            self.iconColor[2], self.iconColor[3])
     self.helpFrame = None
     self.cm = CardMaker('itemCard')
     self.cm.setFrame(-0.29999999999999999, 0.29999999999999999,
                      -0.089999999999999997, 0.089999999999999997)
     self.buffer = None
     self.lens = PerspectiveLens()
     self.lens.setNear(0.5)
     self.lens.setAspectRatio(0.59999999999999998 / 0.17999999999999999)
     self.realItem = None
     self.itemCard = None
     self.portraitSceneGraph = NodePath('PortraitSceneGraph')
     detailGui = loader.loadModel('models/gui/gui_card_detail')
     self.bg = detailGui.find('**/color')
     self.bg.setScale(4)
     self.bg.setPos(0, 17, -6.2999999999999998)
     self.glow = detailGui.find('**/glow')
     self.glow.setScale(3)
     self.glow.setPos(0, 17, -6.2999999999999998)
     self.glow.setColor(1, 1, 1, 0.80000000000000004)
     self.setBin('gui-fixed', 1)
     self.accept('open_main_window', self.createBuffer)
     self.accept('aspectRatioChanged', self.createBuffer)
     self.accept('close_main_window', self.destroyBuffer)
     self.displayHuman = self.manager.getDisplayHuman()
     self.masterHuman = self.manager.getMasterHuman()
예제 #40
0
    def calculateTotalGoldValue(self):
        totalCost = 0
        for cell in self.gridDict.values():
            if cell.inventoryItem:
                totalCost += ItemGlobals.getGoldCost(
                    cell.inventoryItem.getId()) * cell.inventoryItem.amount

        return totalCost
예제 #41
0
 def apply(self, pirate):
     pirate.style.setClothesShirt(0)
     pirate.style.setClothesCoat(0)
     pirate.style.setClothesVest(0)
     pirate.model.handleClothesHiding()
     gender = localAvatar.style.getGender()
     if gender == 'm':
         tattooId = ItemGlobals.getMaleModelId(self.uid)
         if self.zone == TattooGlobals.ZONE3:
             orientation = ItemGlobals.getMaleOrientation2(self.uid)
         else:
             orientation = ItemGlobals.getMaleOrientation(self.uid)
     else:
         tattooId = ItemGlobals.getFemaleModelId(self.uid)
         if self.zone == TattooGlobals.ZONE3:
             orientation = ItemGlobals.getFemaleOrientation2(self.uid)
         else:
             orientation = ItemGlobals.getFemaleOrientation(self.uid)
     (offsetx, offsety, scale, rotate) = ItemGlobals.getOrientation(orientation)
     if not hasattr(pirate, 'model'):
         return None
     
     pirate.model.tattoos[self.zone][TattooGlobals.TYPE] = tattooId
     S = Vec2(1 / float(scale), 1 / float(scale))
     Iv = Vec2(offsetx, offsety)
     Vm = Vec2(sin(rotate * pi / 180.0), cos(rotate * pi / 180.0))
     Vms = Vec2(Vm[0] * S[0], Vm[1] * S[1])
     Vn = Vec2(Vm[1], -Vm[0])
     Vns = Vec2(Vn[0] * S[0], Vn[1] * S[1])
     F = Vec2(-Vns.dot(Iv) + 0.5, -Vms.dot(Iv) + 0.5)
     pirate.model.tattoos[self.zone][TattooGlobals.OFFSETX] = F[0]
     pirate.model.tattoos[self.zone][TattooGlobals.OFFSETY] = F[1]
     pirate.model.tattoos[self.zone][TattooGlobals.SCALE] = S[0]
     pirate.model.tattoos[self.zone][TattooGlobals.ROTATE] = rotate
     pirate.model.updateTattoo(self.zone)
예제 #42
0
 def apply(self, pirate):
     pirate.style.setClothesShirt(0)
     pirate.style.setClothesCoat(0)
     pirate.style.setClothesVest(0)
     pirate.model.handleClothesHiding()
     gender = localAvatar.style.getGender()
     if gender == 'm':
         tattooId = ItemGlobals.getMaleModelId(self.uid)
         if self.zone == TattooGlobals.ZONE3:
             orientation = ItemGlobals.getMaleOrientation2(self.uid)
         else:
             orientation = ItemGlobals.getMaleOrientation(self.uid)
     else:
         tattooId = ItemGlobals.getFemaleModelId(self.uid)
         if self.zone == TattooGlobals.ZONE3:
             orientation = ItemGlobals.getFemaleOrientation2(self.uid)
         else:
             orientation = ItemGlobals.getFemaleOrientation(self.uid)
     (offsetx, offsety, scale, rotate) = ItemGlobals.getOrientation(orientation)
     if not hasattr(pirate, 'model'):
         return None
     
     pirate.model.tattoos[self.zone][TattooGlobals.TYPE] = tattooId
     S = Vec2(1 / float(scale), 1 / float(scale))
     Iv = Vec2(offsetx, offsety)
     Vm = Vec2(sin(rotate * pi / 180.0), cos(rotate * pi / 180.0))
     Vms = Vec2(Vm[0] * S[0], Vm[1] * S[1])
     Vn = Vec2(Vm[1], -Vm[0])
     Vns = Vec2(Vn[0] * S[0], Vn[1] * S[1])
     F = Vec2(-Vns.dot(Iv) + 0.5, -Vms.dot(Iv) + 0.5)
     pirate.model.tattoos[self.zone][TattooGlobals.OFFSETX] = F[0]
     pirate.model.tattoos[self.zone][TattooGlobals.OFFSETY] = F[1]
     pirate.model.tattoos[self.zone][TattooGlobals.SCALE] = S[0]
     pirate.model.tattoos[self.zone][TattooGlobals.ROTATE] = rotate
     pirate.model.updateTattoo(self.zone)
 def updateItemId(self, itemId):
     if self.itemId == itemId:
         return None
     
     self.itemId = itemId
     self.modelId = ItemGlobals.getModel(itemId)
     if hasattr(self, 'prop'):
         self.prop.removeNode()
         self.loadModel()
 def loadModel(self):
     self.prop = self.getModel(self.itemId)
     if ItemGlobals.getSubtype(self.itemId) == ItemGlobals.MUSKET:
         bayonetPart = self.prop.find('**/bayonet')
         if bayonetPart:
             bayonetPart.stash()
         
     
     self.prop.reparentTo(self)
예제 #45
0
 def _TradableInventoryBase__runSelfTest_limits(self, itemCatFilter,
                                                verbose):
     itemIds = ItemGlobals.getAllItemIds()
     for currItemId in itemIds:
         if itemCatFilter != None and itemCatFilter != ItemGlobals.getClass(
                 currItemId):
             itemIds = ItemGlobals.getAllConsumableIds()
             itemLimit = ItemGlobals.getStackLimit(currItemId)
             itemCat = ItemGlobals.getClass(currItemId)
             quantity = self.getItemQuantity(itemCat, currItemId)
         if isStackableType(itemCat):
             pass
         1
         if verbose:
             if not itemLimit:
                 pass
             print 'item limit for item %s:%s passed (quantity: %s limit:%s)' % (
                 itemCat, currItemId, quantity, 1)
    def _TradableInventoryBase__runSelfTest_limits(self, itemCatFilter, verbose):
        itemIds = ItemGlobals.getAllItemIds()
        for currItemId in itemIds:
            if itemCatFilter != None and itemCatFilter != ItemGlobals.getClass(currItemId):
                continue

            itemIds = ItemGlobals.getAllConsumableIds()
            itemLimit = ItemGlobals.getStackLimit(currItemId)
            itemCat = ItemGlobals.getClass(currItemId)
            quantity = self.getItemQuantity(itemCat, currItemId)
            if isStackableType(itemCat):
                pass
            1
            if verbose:
                if not itemLimit:
                    pass
                print 'item limit for item %s:%s passed (quantity: %s limit:%s)' % (itemCat, currItemId, quantity, 1)
                continue
def getItemTrainingReq(itemId):
    typeId = ItemGlobals.getType(itemId)
    if typeId:
        return __itemTrainingList.get(typeId)
    item = __itemList.get(itemId)
    if item:
        return item[6]
    else:
        return 0
 def getStackQuantity(self, stackType):
     itemClass = None
     if isLocatable(stackType):
         itemClass = ItemGlobals.getClass(stackType)
     if itemClass:
         return self.getItemQuantity(itemClass, stackType)
     else:
         return self.getItemQuantity(stackType)
     return
    def getStackQuantity(self, stackType):
        itemClass = None
        if isLocatable(stackType):
            itemClass = ItemGlobals.getClass(stackType)

        if itemClass:
            return self.getItemQuantity(itemClass, stackType)
        else:
            return self.getItemQuantity(stackType)
예제 #50
0
 def avIsReady(self, av):
     inv = av.getInventory()
     if not inv:
         return False
     categoryId = ItemGlobals.getClass(self.itemId)
     if inv.getItemQuantity(categoryId, self.itemId) > 0:
         return True
     else:
         return False
    def __init__(self,
                 manager,
                 itemTuple,
                 imageScaleFactor=0.84999999999999998):
        InventoryUIItem.InventoryUIItem.__init__(
            self, manager, itemTuple, imageScaleFactor=imageScaleFactor)
        self.initialiseoptions(InventoryUITattooItem)
        self['relief'] = None
        tattooGui = loader.loadModel('models/misc/tattoos')
        image = tattooGui.find('**/%s' % ItemGlobals.getIcon(itemTuple[1]))
        if image.isEmpty():
            image = tattooGui.find('**/tattoo_%s' %
                                   ItemGlobals.getIcon(itemTuple[1]))

        self['image'] = image
        self['image_scale'] = 0.10000000000000001 * imageScaleFactor
        self.iconColor = (1.0, 1.0, 1.0, 1.0)
        self['image_color'] = (self.iconColor[0], self.iconColor[1],
                               self.iconColor[2], self.iconColor[3])
        self.helpFrame = None
        self.cm = CardMaker('itemCard')
        self.cm.setFrame(-0.29999999999999999, 0.29999999999999999,
                         -0.089999999999999997, 0.089999999999999997)
        self.buffer = None
        self.lens = PerspectiveLens()
        self.lens.setNear(0.10000000000000001)
        self.lens.setAspectRatio(0.59999999999999998 / 0.17999999999999999)
        self.realItem = None
        self.itemCard = None
        self.portraitSceneGraph = NodePath('PortraitSceneGraph')
        detailGui = loader.loadModel('models/gui/gui_card_detail')
        self.bg = detailGui.find('**/color')
        self.bg.setScale(4)
        self.bg.setPos(0, 17, -6.2999999999999998)
        self.glow = detailGui.find('**/glow')
        self.glow.setScale(3)
        self.glow.setPos(0, 17, -6.2999999999999998)
        self.glow.setColor(1, 1, 1, 0.80000000000000004)
        self.setBin('gui-fixed', 1)
        self.accept('open_main_window', self.createBuffer)
        self.accept('aspectRatioChanged', self.createBuffer)
        self.accept('close_main_window', self.destroyBuffer)
        self.displayHuman = self.manager.getDisplayHuman()
        self.masterHuman = self.manager.getMasterHuman()
def getItemType(itemId):
    typeId = ItemGlobals.getType(itemId)
    if typeId:
        return __itemTypeNameList.get(typeId)

    item = __itemList.get(itemId)
    if item:
        return item[2]
    else:
        return None
예제 #53
0
 def addTab(self, itemGroup, item):
     newTab = self.tabBar.addTab(itemGroup,
                                 command=self.setPage,
                                 extraArgs=[itemGroup])
     repId = WeaponGlobals.getRepId(item)
     if repId:
         iconName = ReputationGlobals.RepIcons.get(repId)
         if repId == InventoryType.FishingRep:
             icon = StoreGUI.FishingIcons.find('**/%s' % iconName)
         else:
             icon = StoreGUI.WeaponIcons.find('**/%s' % iconName)
     elif InventoryType.begin_Consumables <= item:
         pass
     elif repId or ItemGlobals.getClass(
             item) == InventoryType.ItemTypeConsumable:
         iconName = EconomyGlobals.getItemIcons(item)
         icon = StoreGUI.SkillIcons.find('**/%s' % iconName)
     elif InventoryType.begin_WeaponCannonAmmo <= item:
         pass
     elif ItemGlobals.getClass(item) == InventoryType.ItemTypeConsumable:
         iconName = EconomyGlobals.getItemIcons(InventoryType.CannonL1)
         icon = StoreGUI.WeaponIcons.find('**/%s' % iconName)
     elif InventoryType.begin_WeaponGrenadeAmmo <= item:
         pass
     elif ItemGlobals.getClass(item) == InventoryType.ItemTypeConsumable:
         itemId = InventoryType.GrenadeWeaponL1
         iconName = EconomyGlobals.getItemIcons(itemId)
         icon = StoreGUI.WeaponIcons.find('**/%s' % iconName)
     elif InventoryType.begin_FishingLures <= item:
         pass
     elif ItemGlobals.getClass(item) == InventoryType.ItemTypeConsumable:
         icon = StoreGUI.FishingIcons.find('**/pir_t_gui_gen_fish_lure')
     else:
         icon = None
     newTab.nameTag = DirectLabel(parent=newTab,
                                  relief=None,
                                  state=DGG.DISABLED,
                                  image=icon,
                                  image_scale=0.40000000000000002,
                                  image_pos=(0, 0, 0.040000000000000001),
                                  pos=(0.059999999999999998, 0,
                                       -0.035000000000000003))
     self.pageNames.append(itemGroup)
    def avIsReady(self, av):
        inv = av.getInventory()
        if not inv:
            return False

        categoryId = ItemGlobals.getClass(self.itemId)
        if inv.getItemQuantity(categoryId, self.itemId) > 0:
            return True
        else:
            return False
def getItemType(itemId):
    typeId = ItemGlobals.getType(itemId)
    if typeId:
        return __itemTypeNameList.get(typeId)
    
    item = __itemList.get(itemId)
    if item:
        return item[2]
    else:
        return None
def getItemTrainingReq(itemId):
    typeId = ItemGlobals.getType(itemId)
    if typeId:
        return __itemTrainingList.get(typeId)
    
    item = __itemList.get(itemId)
    if item:
        return item[6]
    else:
        return 0
    def updateSkillId(self, skillId):
        self.skillId = skillId
        if self.skillButton:
            if self.quantityLabel:
                self.quantityLabel.detachNode()

            self.skillButton.destroy()

        if self.showQuantity and not (self.quantity):
            geomColor = Vec4(0.5, 0.5, 0.5, 1.0)
        else:
            geomColor = Vec4(1.0, 1.0, 1.0, 1.0)
        if self.showIcon:
            asset = WeaponGlobals.getSkillIcon(skillId)
            if hasattr(self, '_skillIconName'):
                asset = self._skillIconName

            geom = SkillButton.SkillIcons.find('**/%s' % asset)
            if geom.isEmpty():
                geom = SkillButton.SkillIcons.find('**/base')

            repId = WeaponGlobals.getSkillReputationCategoryId(self.skillId)
            geom_scale = getGeomScale(repId, skillId)
            image_color = (1, 1, 1, 1)
        else:
            geom = (None,)
            geom_scale = 0.12
            image_color = (0.5, 0.5, 0.5, 0.5)
        specialIconId = 0
        if self.isBreakAttackSkill:
            specialIconId = 1
        elif self.isDefenseSkill:
            specialIconId = 2
        elif skillId == ItemGlobals.getSpecialAttack(localAvatar.currentWeaponId):
            specialIconId = 3

        if specialIconId:
            something = SkillButton.SpecialIcons[specialIconId][0]
            if self.skillRing:
                self.skillRing.setupFace(something)

            self['image'] = None
        elif self.skillRing:
            self.skillRing.setupFace()

        if self.showRing:
            image = None
        else:
            image = SkillButton.Image
        self.skillButton = DirectButton(parent = self, relief = None, pos = (0, 0, 0), text = ('', '', self.name), text_align = TextNode.ACenter, text_shadow = Vec4(0, 0, 0, 1), text_scale = 0.040000000000000001, text_fg = Vec4(1, 1, 1, 1), text_pos = (0.0, 0.089999999999999997), image = image, image_scale = 0.14999999999999999, image_color = image_color, geom = geom, geom_scale = geom_scale, geom_color = geomColor, command = self.callback, sortOrder = 50, extraArgs = [
            skillId])
        self.skillButton.bind(DGG.ENTER, self.showDetails)
        self.skillButton.bind(DGG.EXIT, self.hideDetails)
        if self.quantityLabel and not self.quantityLabel.isEmpty():
            self.quantityLabel.reparentTo(self.skillButton)
예제 #58
0
 def doAttack(self, attacker, skillId, ammoSkillId, targetId, areaIdList, pos, combo = 0, charge = 0):
     attacker.battleRandom.advanceAttackSeed()
     if targetId:
         if WeaponGlobals.getIsShipSkill(skillId):
             target = base.cr.doId2do.get(targetId)
         elif WeaponGlobals.getIsDollAttackSkill(skillId):
             target = base.cr.doId2do.get(targetId)
         else:
             target = base.cr.doId2do.get(targetId)
             if hasattr(target, 'getSkillEffects'):
                 if WeaponGlobals.C_SPAWN in set(target.getSkillEffects()):
                     return WeaponGlobals.RESULT_MISS
                 
             
             if target and not TeamUtils.damageAllowed(localAvatar, target) and not WeaponGlobals.isFriendlyFire(skillId, ammoSkillId):
                 return WeaponGlobals.RESULT_NOT_AVAILABLE
             
     else:
         target = None
     weaponHit = self.willWeaponHit(attacker, target, skillId, ammoSkillId, charge)
     if combo == -1:
         if localAvatar.wantComboTiming:
             return WeaponGlobals.RESULT_MISS
         
     
     if not WeaponGlobals.getNeedTarget(skillId, ammoSkillId):
         return WeaponGlobals.RESULT_HIT
     
     if not target and not areaIdList:
         messenger.send('tooFar')
         return WeaponGlobals.RESULT_MISS
     
     if target and not self.obeysPirateCode(attacker, target):
         if ItemGlobals.getSubtype(localAvatar.currentWeaponId) == ItemGlobals.BAYONET:
             pass
         if not (WeaponGlobals.getAttackClass(skillId) == WeaponGlobals.AC_COMBAT):
             return WeaponGlobals.RESULT_AGAINST_PIRATE_CODE
         
     if target and not self.targetInRange(attacker, target, skillId, ammoSkillId, pos):
         return WeaponGlobals.RESULT_OUT_OF_RANGE
     
     if target and isinstance(target, DistributedBattleNPC.DistributedBattleNPC):
         if target.getGameState()[0] == 'BreakCombat':
             return WeaponGlobals.RESULT_MISS
         
     
     if target:
         skillEffects = target.getSkillEffects()
         if WeaponGlobals.C_SPAWN in skillEffects:
             return WeaponGlobals.RESULT_MISS
         
     
     messenger.send('properHit')
     return weaponHit
 def takeAim(self, av, skillId = None, ammoSkillId = None):
     if not self.aimTrav:
         return (None, None)
     
     self.aimTrav.traverse(render)
     numEntries = self.aimQueue.getNumEntries()
     if numEntries == 0:
         return (None, None)
     
     self.aimQueue.sortEntries()
     avTeam = av.getTeam()
     (currentWeaponId, isWeaponDrawn) = av.getCurrentWeapon()
     friendlyWeapon = WeaponGlobals.isFriendlyFireWeapon(currentWeaponId)
     if skillId:
         friendlySkill = WeaponGlobals.isFriendlyFire(skillId, ammoSkillId)
     
     for i in range(numEntries):
         entry = self.aimQueue.getEntry(i)
         targetColl = entry.getIntoNodePath()
         if targetColl.node().getIntoCollideMask().hasBitsInCommon(PiratesGlobals.BattleAimOccludeBitmask):
             break
         
         target = self.getObjectFromNodepath(targetColl)
         if target:
             if targetColl.hasNetPythonTag('MonstrousObject'):
                 dist = entry.getSurfacePoint(localAvatar)[1]
             else:
                 dist = target.getY(av)
             targetTeam = target.getTeam()
             if target.gameFSM.state == 'Death':
                 continue
             
             if dist < 0:
                 continue
             
             if not TeamUtils.damageAllowed(target, localAvatar):
                 if not friendlyWeapon:
                     continue
                 
                 if skillId and not friendlySkill:
                     continue
                 
             
             if not self.cr.battleMgr.obeysPirateCode(av, target):
                 if ItemGlobals.getSubtype(av.currentWeaponId) != ItemGlobals.BAYONET:
                     localAvatar.guiMgr.showPirateCode()
                     continue
                 
             
             return (target, dist)
             continue
         continue
     
     return (None, None)