def isComboSkill(skillId): inv = base.localAvatar.getInventory() if inv == None: return 0 if skillId == InventoryType.DollAttune or skillId == InventoryType.DollPoke: return 0 if WeaponGlobals.getSkillTrack(skillId) == 1: if inv.getStackQuantity(skillId): return 1 return 0
def isComboSkill(skillId): inv = base.localAvatar.getInventory() if inv == None: return 0 if skillId == InventoryType.DollAttune or skillId == InventoryType.DollPoke: return 0 if WeaponGlobals.getSkillTrack(skillId) == 1: if inv.getStackQuantity(skillId): return 1 return 0
def getTimeSpentRecharging(self, skillId): if WeaponGlobals.getSkillTrack( skillId) == WeaponGlobals.BREAK_ATTACK_SKILL_INDEX: return self.getHits(skillId) details = self.__timers.get(skillId) if not details: return None t = details[1] if details[0] == self.CHARGING: curTime = globalClock.getFrameTime() lastTime = details[2] dt = curTime - lastTime t += dt return t
def getTimeSpentRecharging(self, skillId): if WeaponGlobals.getSkillTrack(skillId) == WeaponGlobals.BREAK_ATTACK_SKILL_INDEX: return self.getHits(skillId) details = self._BattleSkillDiary__timers.get(skillId) if not details: return None t = details[1] if details[0] == self.CHARGING: curTime = globalClock.getFrameTime() lastTime = details[2] dt = curTime - lastTime t += dt return t
def canUseSkill(self, skillId, ammoSkillId, tolerance=0.0): timeRequired = self.cr.battleMgr.getModifiedRechargeTime( self.av, skillId, ammoSkillId) if timeRequired == 0.0: return 1 timeSpent = self.getTimeSpentRecharging(skillId) if timeSpent is None: return 1 if WeaponGlobals.getSkillTrack( skillId) == WeaponGlobals.BREAK_ATTACK_SKILL_INDEX: if timeSpent >= timeRequired: return 1 return 0 if timeSpent + tolerance >= timeRequired: return 1 elif skillId == InventoryType.CannonShoot: return 1 else: return 0 return
def getTimeRemaining(self, skillId): if WeaponGlobals.getSkillTrack(skillId) == WeaponGlobals.BREAK_ATTACK_SKILL_INDEX: ammoSkillId = 0 else: details = self._BattleSkillDiary__timers.get(skillId) if not details: return None ammoSkillId = details[3] timeRequired = self.cr.battleMgr.getModifiedRechargeTime(self.av, skillId, ammoSkillId) if timeRequired == 0.0: return 0.0 timeSpent = self.getTimeSpentRecharging(skillId) if timeSpent is None: return 0.0 elif timeSpent >= timeRequired: return 0.0 else: return timeRequired - timeSpent
def canUseSkill(self, skillId, ammoSkillId, tolerance = 0.0): timeRequired = self.cr.battleMgr.getModifiedRechargeTime(self.av, skillId, ammoSkillId) if timeRequired == 0.0: return 1 timeSpent = self.getTimeSpentRecharging(skillId) if timeSpent is None: return 1 if WeaponGlobals.getSkillTrack(skillId) == WeaponGlobals.BREAK_ATTACK_SKILL_INDEX: if timeSpent >= timeRequired: return 1 return 0 if timeSpent + tolerance >= timeRequired: return 1 elif skillId == InventoryType.CannonShoot: return 1 else: return 0
def getAllSkills(repId, skilltrack, wantWeaponSkill = 0): inv = base.localAvatar.getInventory() if inv == None: print 'WARNING - getAllSkills came up with no inventory for ', repId return [] minlvl = 2 choices = [] if repId == InventoryType.CutlassRep: skillId = InventoryType.begin_WeaponSkillCutlass while skillId < InventoryType.end_WeaponSkillCutlass: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: locked = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): locked = not WeaponGlobals.canFreeUse(skillId) if inv.getStackQuantity(skillId) >= minlvl: skill = (skillId, True, locked) else: skill = (skillId, False, locked) choices.append(skill) skillId += 1 elif repId == InventoryType.MeleeRep: skillId = InventoryType.begin_WeaponSkillMelee while skillId < InventoryType.end_WeaponSkillMelee: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: locked = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): locked = not WeaponGlobals.canFreeUse(skillId) if inv.getStackQuantity(skillId) >= minlvl: skill = (skillId, True, locked) else: skill = (skillId, False, locked) choices.append(skill) skillId += 1 elif repId == InventoryType.DaggerRep: skillId = InventoryType.begin_WeaponSkillDagger while skillId < InventoryType.end_WeaponSkillDagger: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: locked = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): locked = not WeaponGlobals.canFreeUse(skillId) if inv.getStackQuantity(skillId) >= minlvl: skill = (skillId, True, locked) else: skill = (skillId, False, locked) choices.append(skill) skillId += 1 elif repId == InventoryType.GrenadeRep: skillId = InventoryType.begin_WeaponSkillGrenade while skillId < InventoryType.end_WeaponSkillGrenade: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: locked = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): locked = not WeaponGlobals.canFreeUse(skillId) if inv.getStackQuantity(skillId) >= minlvl: skill = (skillId, True, locked) else: skill = (skillId, False, locked) choices.append(skill) skillId += 1 elif repId == InventoryType.DollRep: skillId = InventoryType.begin_WeaponSkillDoll while skillId < InventoryType.end_WeaponSkillDoll: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: locked = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): locked = not WeaponGlobals.canFreeUse(skillId) if inv.getStackQuantity(skillId) >= minlvl: skill = (skillId, True, locked) else: skill = (skillId, False, locked) choices.append(skill) skillId += 1 elif repId == InventoryType.WandRep: skillId = InventoryType.begin_WeaponSkillWand while skillId < InventoryType.end_WeaponSkillWand: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: locked = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): locked = not WeaponGlobals.canFreeUse(skillId) if inv.getStackQuantity(skillId) >= minlvl: skill = (skillId, True, locked) else: skill = (skillId, False, locked) choices.append(skill) skillId += 1 elif repId == InventoryType.KettleRep: skillId = InventoryType.begin_WeaponSkillKettle while skillId < InventoryType.end_WeaponSkillKettle: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: locked = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): locked = not WeaponGlobals.canFreeUse(skillId) if inv.getStackQuantity(skillId) >= minlvl: skill = (skillId, True, locked) else: skill = (skillId, False, locked) choices.append(skill) skillId += 1 elif repId == InventoryType.PistolRep: skillId = InventoryType.begin_WeaponSkillPistol while skillId < InventoryType.end_WeaponSkillPistol: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: locked = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): locked = not WeaponGlobals.canFreeUse(skillId) if inv.getStackQuantity(skillId) >= minlvl: skill = (skillId, True, locked) else: skill = (skillId, False, locked) choices.append(skill) skillId += 1 elif repId == InventoryType.CannonRep: wantWeaponSkill = 0 skillId = InventoryType.begin_WeaponSkillCannon while skillId < InventoryType.end_WeaponSkillCannon: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: locked = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): locked = not WeaponGlobals.canFreeUse(skillId) if inv.getStackQuantity(skillId) >= minlvl: skill = (skillId, True, locked) else: skill = (skillId, False, locked) choices.append(skill) skillId += 1 elif repId == InventoryType.SailingRep: skillId = InventoryType.begin_SkillSailing while skillId < InventoryType.end_SkillSailing: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: locked = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): locked = not WeaponGlobals.canFreeUse(skillId) shouldBeVisible = inv.getStackQuantity(skillId) >= minlvl skill = (skillId, shouldBeVisible, locked) choices.append(skill) skillId += 1 elif repId == InventoryType.DefenseCannonRep: wantWeaponSkill = 0 for skillId in PiratesGlobals.CANNON_DEFENSE_SKILLS: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: skill = (skillId, True, False) choices.append(skill) skillId += 1 elif repId == InventoryType.FishingRep: wantWeaponSkill = 0 skillId = InventoryType.begin_WeaponSkillFishingRod skilltrack = 1 while skillId < InventoryType.end_WeaponSkillFishingRod: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: locked = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): locked = not WeaponGlobals.canFreeUse(skillId) if inv.getStackQuantity(skillId) >= minlvl: skill = (skillId, True, locked) else: skill = (skillId, False, locked) choices.append(skill) skillId += 1 if wantWeaponSkill: weaponSkill = getWeaponSkill(repId) if weaponSkill: choices.append((weaponSkill, True, 0)) return choices
def FindSkills(repId, skilltrack, minlvl): inv = base.localAvatar.getInventory() if inv == None: print 'WARNING - FindSkills came up with no inventory for ', repId return [] choices = [] if repId == InventoryType.FishingRep: skillId = InventoryType.begin_WeaponSkillFishingRod while skillId < InventoryType.end_WeaponSkillFishingRod: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: if inv.getStackQuantity(skillId) >= minlvl: choices.append(skillId) skillId += 1 if repId == InventoryType.CutlassRep: skillId = InventoryType.begin_WeaponSkillCutlass while skillId < InventoryType.end_WeaponSkillCutlass: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: if inv.getStackQuantity(skillId) >= minlvl: choices.append(skillId) skillId += 1 elif repId == InventoryType.MeleeRep: skillId = InventoryType.begin_WeaponSkillMelee while skillId < InventoryType.end_WeaponSkillMelee: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: if inv.getStackQuantity(skillId) >= minlvl: choices.append(skillId) skillId += 1 elif repId == InventoryType.DaggerRep: skillId = InventoryType.begin_WeaponSkillDagger while skillId < InventoryType.end_WeaponSkillDagger: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: if inv.getStackQuantity(skillId) >= minlvl: choices.append(skillId) skillId += 1 elif repId == InventoryType.GrenadeRep: skillId = InventoryType.begin_WeaponSkillGrenade while skillId < InventoryType.end_WeaponSkillGrenade: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: if inv.getStackQuantity(skillId) >= minlvl: choices.append(skillId) skillId += 1 elif repId == InventoryType.DollRep: skillId = InventoryType.begin_WeaponSkillDoll while skillId < InventoryType.end_WeaponSkillDoll: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: if inv.getStackQuantity(skillId) >= minlvl: choices.append(skillId) skillId += 1 elif repId == InventoryType.WandRep: skillId = InventoryType.begin_WeaponSkillWand while skillId < InventoryType.end_WeaponSkillWand: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: if inv.getStackQuantity(skillId) >= minlvl: choices.append(skillId) skillId += 1 elif repId == InventoryType.KettleRep: skillId = InventoryType.begin_WeaponSkillKettle while skillId < InventoryType.end_WeaponSkillKettle: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: if inv.getStackQuantity(skillId) >= minlvl: choices.append(skillId) skillId += 1 elif repId == InventoryType.PistolRep: skillId = InventoryType.begin_WeaponSkillPistol while skillId < InventoryType.end_WeaponSkillPistol: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: if inv.getStackQuantity(skillId) >= minlvl: choices.append(skillId) skillId += 1 elif repId == InventoryType.CannonRep: skillId = InventoryType.begin_WeaponSkillCannon while skillId < InventoryType.end_WeaponSkillCannon: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: if inv.getStackQuantity(skillId) >= minlvl: choices.append(skillId) skillId += 1 elif repId == InventoryType.SailingRep: skillId = InventoryType.begin_SkillSailing while skillId < InventoryType.end_SkillSailing: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: if inv.getStackQuantity(skillId) >= minlvl: choices.append(skillId) skillId += 1 elif repId == InventoryType.DefenseCannonRep: for skillId in PiratesGlobals.CANNON_DEFENSE_SKILLS: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: if inv.getStackQuantity(skillId) >= minlvl: choices.append(skillId) skillId += 1 return choices
def showDetails(self, cell, detailsPos, detailsHeight, event = None): self.notify.debug('Item showDetails') if self.manager.heldItem and self.manager.locked and cell.isEmpty() and self.isEmpty() or not (self.itemTuple): self.notify.debug(' early exit') return None inv = localAvatar.getInventory() if not inv: return None itemId = self.getId() self.helpFrame = DirectFrame(parent = self.manager, relief = None, state = DGG.DISABLED, sortOrder = 1) self.helpFrame.setBin('gui-popup', -5) detailGui = loader.loadModel('models/gui/gui_card_detail') topGui = loader.loadModel('models/gui/toplevel_gui') coinImage = topGui.find('**/treasure_w_coin*') self.SkillIcons = loader.loadModel('models/textureCards/skillIcons') self.BuffIcons = loader.loadModel('models/textureCards/buff_icons') border = self.SkillIcons.find('**/base') halfWidth = 0.29999999999999999 halfHeight = 0.20000000000000001 basePosX = cell.getX(aspect2d) basePosZ = cell.getZ(aspect2d) cellSizeX = 0.0 cellSizeZ = 0.0 if cell: cellSizeX = cell.cellSizeX cellSizeZ = cell.cellSizeZ textScale = PiratesGuiGlobals.TextScaleMed titleScale = PiratesGuiGlobals.TextScaleTitleSmall if len(self.getName()) >= 30: titleNameScale = PiratesGuiGlobals.TextScaleLarge else: titleNameScale = PiratesGuiGlobals.TextScaleExtraLarge subtitleScale = PiratesGuiGlobals.TextScaleMed iconScalar = 1.5 borderScaler = 0.25 splitHeight = 0.01 vMargin = 0.029999999999999999 runningVertPosition = 0.29999999999999999 runningSize = 0.0 labels = [] titleColor = PiratesGuiGlobals.TextFG6 rarity = ItemGlobals.getRarity(itemId) rarityText = PLocalizer.getItemRarityName(rarity) subtypeText = PLocalizer.getItemSubtypeName(ItemGlobals.getSubtype(itemId)) if rarity == ItemGlobals.CRUDE: titleColor = PiratesGuiGlobals.TextFG24 elif rarity == ItemGlobals.COMMON: titleColor = PiratesGuiGlobals.TextFG13 elif rarity == ItemGlobals.RARE: titleColor = PiratesGuiGlobals.TextFG4 elif rarity == ItemGlobals.FAMED: titleColor = PiratesGuiGlobals.TextFG5 titleLabel = DirectLabel(parent = self, relief = None, text = self.getName(), text_scale = titleNameScale, text_fg = titleColor, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) self.bg.setColor(titleColor) tHeight = 0.070000000000000007 titleLabel.setZ(runningVertPosition) runningVertPosition -= tHeight runningSize += tHeight labels.append(titleLabel) subtitleLabel = DirectLabel(parent = self, relief = None, text = 'slant%s %s' % (rarityText, subtypeText), text_scale = subtitleScale, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) subtHeight = 0.050000000000000003 subtitleLabel.setZ(subtHeight * 0.5 + runningVertPosition) runningVertPosition -= subtHeight runningSize += subtHeight labels.append(subtitleLabel) itemType = ItemGlobals.getType(itemId) itemSubtype = ItemGlobals.getSubtype(itemId) model = ItemGlobals.getModel(itemId) if model: self.realItem = loader.loadModel('models/inventory/' + model) if self.realItem: posHpr = ItemGlobals.getModelPosHpr(model) if posHpr: self.realItem.setPos(posHpr[0], posHpr[1], posHpr[2]) self.realItem.setHpr(posHpr[3], posHpr[4], posHpr[5]) elif itemSubtype == ItemGlobals.RAM: self.realItem.setPos(-1.5, 1.5, -0.59999999999999998) self.realItem.setHpr(70, 160, -90) else: self.realItem.setPos(0.0, 1.5, -0.059999999999999998) self.realItem.setHpr(0, 90, 0) self.realItem.reparentTo(self.portraitSceneGraph) iHeight = 0.17999999999999999 self.createBuffer() self.itemCard.setZ(runningVertPosition - 0.059999999999999998) runningVertPosition -= iHeight runningSize += iHeight labels.append(self.itemCard) goldLabel = DirectLabel(parent = self, relief = None, image = coinImage, image_scale = 0.12, image_pos = Vec3(0.025000000000000001, 0, -0.02), text = str(int(ItemGlobals.getGoldCost(itemId) * ItemGlobals.GOLD_SALE_MULTIPLIER)), text_scale = subtitleScale, text_align = TextNode.ARight, text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, pos = (halfWidth - 0.050000000000000003, 0.0, runningVertPosition + 0.080000000000000002), text_pos = (0.0, -textScale)) labels.append(goldLabel) specialAttack = ItemGlobals.getSpecialAttack(itemId) if specialAttack: attackIcon = self.SkillIcons.find('**/%s' % WeaponGlobals.getSkillIcon(specialAttack)) specialAttackNameLabel = DirectLabel(parent = self, relief = None, image = border, image_scale = 0.10000000000000001, geom = attackIcon, geom_scale = 0.10000000000000001, image_pos = (-0.070000000000000007, 0.0, -0.050000000000000003), geom_pos = (-0.070000000000000007, 0.0, -0.050000000000000003), text = PLocalizer.getInventoryTypeName(specialAttack), text_scale = PiratesGuiGlobals.TextScaleLarge, text_wordwrap = halfWidth * 2.0 * (0.90000000000000002 / titleScale), text_align = TextNode.ALeft, text_fg = titleColor, text_font = PiratesGlobals.getInterfaceOutlineFont(), pos = (-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) specialAttackRankLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.ItemRank % ItemGlobals.getSpecialAttackRank(itemId), text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.90000000000000002 / titleScale), text_align = TextNode.ARight, pos = (halfWidth - textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) specialAttackType = WeaponGlobals.getSkillTrack(specialAttack) if specialAttackType == WeaponGlobals.BREAK_ATTACK_SKILL_INDEX: specialAttackTypeText = PLocalizer.BreakAttackSkill elif specialAttackType == WeaponGlobals.DEFENSE_SKILL_INDEX: specialAttackTypeText = PLocalizer.DefenseSkill else: specialAttackTypeText = PLocalizer.WeaponSkill specialAttackTypeLabel = DirectLabel(parent = self, relief = None, text = specialAttackTypeText, text_scale = PiratesGuiGlobals.TextScaleLarge, text_wordwrap = halfWidth * 2.7999999999999998 * (0.90000000000000002 / titleScale), text_align = TextNode.ALeft, pos = (-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition - PiratesGuiGlobals.TextScaleLarge), text_pos = (0.0, -textScale)) specialAttackInfo = PLocalizer.SkillDescriptions.get(specialAttack) specialAttackDescriptionText = specialAttackInfo[1] specialAttackDescriptionLabel = DirectLabel(parent = self, relief = None, text = specialAttackDescriptionText, text_scale = textScale, text_wordwrap = halfWidth * 2.7999999999999998 * (0.90000000000000002 / titleScale), text_align = TextNode.ALeft, pos = (-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition - specialAttackNameLabel.getHeight() + specialAttackTypeLabel.getHeight() - 0.059999999999999998), text_pos = (0.0, -textScale)) saHeight = specialAttackNameLabel.getHeight() + specialAttackTypeLabel.getHeight() + specialAttackDescriptionLabel.getHeight() - 0.040000000000000001 runningVertPosition -= saHeight runningSize += saHeight labels.append(specialAttackNameLabel) labels.append(specialAttackRankLabel) labels.append(specialAttackTypeLabel) labels.append(specialAttackDescriptionLabel) attributes = ItemGlobals.getAttributes(itemId) for i in range(0, len(attributes)): attributeIcon = self.SkillIcons.find('**/%s' % ItemGlobals.getAttributeIcon(attributes[i][0])) if not attributeIcon: attributeIcon = self.BuffIcons.find('**/%s' % ItemGlobals.getAttributeIcon(attributes[i][0])) attributeNameLabel = DirectLabel(parent = self, relief = None, image = border, image_scale = 0.050000000000000003, geom = attributeIcon, geom_scale = 0.050000000000000003, image_pos = (-0.070000000000000007, 0.0, -0.029999999999999999), geom_pos = (-0.070000000000000007, 0.0, -0.029999999999999999), text = PLocalizer.getItemAttributeName(attributes[i][0]), text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.90000000000000002 / titleScale), text_align = TextNode.ALeft, text_fg = titleColor, text_font = PiratesGlobals.getInterfaceOutlineFont(), pos = (-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) attributeRankLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.ItemRank % attributes[i][1], text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.90000000000000002 / titleScale), text_align = TextNode.ARight, pos = (halfWidth - textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) if attributeNameLabel.getHeight() > 0.074999999999999997: attributeNameSpace = 0.080000000000000002 else: attributeNameSpace = PiratesGuiGlobals.TextScaleLarge attributeDescriptionLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.getItemAttributeDescription(attributes[i][0]), text_scale = textScale, text_wordwrap = halfWidth * 2.7999999999999998 * (0.90000000000000002 / titleScale), text_align = TextNode.ALeft, pos = (-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition - attributeNameSpace), text_pos = (0.0, -textScale)) aHeight = attributeNameLabel.getHeight() + attributeDescriptionLabel.getHeight() runningVertPosition -= aHeight + splitHeight runningSize += aHeight + splitHeight labels.append(attributeNameLabel) labels.append(attributeRankLabel) labels.append(attributeDescriptionLabel) skillBoosts = ItemGlobals.getSkillBoosts(itemId) for i in range(0, len(skillBoosts)): boostIcon = self.SkillIcons.find('**/%s' % WeaponGlobals.getSkillIcon(skillBoosts[i][0])) boostNameLabel = DirectLabel(parent = self, relief = None, image = border, image_scale = 0.050000000000000003, geom = boostIcon, geom_scale = 0.050000000000000003, image_pos = (-0.070000000000000007, 0.0, -0.029999999999999999), geom_pos = (-0.070000000000000007, 0.0, -0.029999999999999999), text = PLocalizer.ItemBoost % PLocalizer.getInventoryTypeName(skillBoosts[i][0]), text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.90000000000000002 / titleScale), text_align = TextNode.ALeft, pos = (-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) boostRankLabel = DirectLabel(parent = self, relief = None, text = '+%s' % str(skillBoosts[i][1]), text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.90000000000000002 / titleScale), text_align = TextNode.ARight, pos = (halfWidth - textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) bHeight = boostNameLabel.getHeight() runningVertPosition -= bHeight + splitHeight runningSize += bHeight + splitHeight labels.append(boostNameLabel) labels.append(boostRankLabel) description = PLocalizer.getItemFlavorText(itemId) if description != '': descriptionLabel = DirectLabel(parent = self, relief = None, text = description, text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.94999999999999996 / textScale), text_align = TextNode.ALeft, pos = (-halfWidth + textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) dHeight = descriptionLabel.getHeight() + 0.02 runningVertPosition -= dHeight runningSize += dHeight labels.append(descriptionLabel) weaponLevel = 0 weaponRepId = WeaponGlobals.getRepId(itemId) weaponRep = inv.getReputation(weaponRepId) weaponReq = ItemGlobals.getWeaponRequirement(itemId) weaponText = None if weaponReq: weaponLevel = ReputationGlobals.getLevelFromTotalReputation(weaponRepId, weaponRep)[0] if weaponLevel < weaponReq: weaponColor = PiratesGuiGlobals.TextFG6 else: weaponColor = (0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1.0) weaponText = PLocalizer.ItemLevelRequirement % (weaponReq, PLocalizer.getItemTypeName(itemType)) else: trainingToken = EconomyGlobals.getItemTrainingReq(itemId) trainingAmt = inv.getItemQuantity(trainingToken) if trainingAmt == 0: weaponColor = PiratesGuiGlobals.TextFG6 weaponText = PLocalizer.ItemTrainingRequirement % PLocalizer.getItemTypeName(itemType) if weaponText: weaponReqLabel = DirectLabel(parent = self, relief = None, text = weaponText, text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (1.5 / titleScale), text_fg = weaponColor, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) wHeight = weaponReqLabel.getHeight() runningVertPosition -= wHeight runningSize += wHeight labels.append(weaponReqLabel) if not Freebooter.getPaidStatus(localAvatar.getDoId()): if rarity != ItemGlobals.CRUDE: unlimitedLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.UnlimitedAccessRequirement, text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (1.5 / titleScale), text_fg = PiratesGuiGlobals.TextFG6, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) uHeight = unlimitedLabel.getHeight() runningVertPosition -= uHeight runningSize += uHeight labels.append(unlimitedLabel) runningVertPosition -= 0.02 runningSize += 0.02 panels = self.helpFrame.attachNewNode('panels') topPanel = panels.attachNewNode('middlePanel') detailGui.find('**/top_panel').copyTo(topPanel) topPanel.setScale(0.080000000000000002) topPanel.reparentTo(self.helpFrame) middlePanel = panels.attachNewNode('middlePanel') detailGui.find('**/middle_panel').copyTo(middlePanel) middlePanel.setScale(0.080000000000000002) middlePanel.reparentTo(self.helpFrame) placement = 0 i = 0 heightMax = -0.080000000000000002 currentHeight = runningVertPosition while currentHeight < heightMax: middlePanel = panels.attachNewNode('middlePanel%s' % 1) detailGui.find('**/middle_panel').copyTo(middlePanel) middlePanel.setScale(0.080000000000000002) middlePanel.reparentTo(self.helpFrame) if currentHeight + 0.20000000000000001 >= heightMax: difference = heightMax - currentHeight placement += (0.16800000000000001 / 0.20000000000000001) * difference currentHeight += difference else: placement += 0.16800000000000001 currentHeight += 0.20000000000000001 middlePanel.setZ(-placement) i += 1 bottomPanel = panels.attachNewNode('bottomPanel') detailGui.find('**/bottom_panel').copyTo(bottomPanel) bottomPanel.setScale(0.080000000000000002) bottomPanel.setZ(-placement) bottomPanel.reparentTo(self.helpFrame) colorPanel = panels.attachNewNode('colorPanel') detailGui.find('**/color').copyTo(colorPanel) colorPanel.setScale(0.080000000000000002) colorPanel.setColor(titleColor) colorPanel.reparentTo(self.helpFrame) lineBreakTopPanel = panels.attachNewNode('lineBreakTopPanel') detailGui.find('**/line_break_top').copyTo(lineBreakTopPanel) lineBreakTopPanel.setScale(0.080000000000000002, 0.080000000000000002, 0.070000000000000007) lineBreakTopPanel.setZ(0.0080000000000000002) lineBreakTopPanel.reparentTo(self.helpFrame) panels.flattenStrong() self.helpFrame['frameSize'] = (-halfWidth, halfWidth, -(runningSize + vMargin), vMargin) totalHeight = self.helpFrame.getHeight() - 0.10000000000000001 for label in labels: label.reparentTo(self.helpFrame) if basePosX > 0.0: newPosX = basePosX - halfWidth + cellSizeX * 0.45000000000000001 else: newPosX = basePosX + halfWidth + cellSizeX * 0.45000000000000001 if basePosZ > 0.0: newPosZ = basePosZ + cellSizeZ * 0.45000000000000001 else: newPosZ = basePosZ + totalHeight - cellSizeZ * 0.75 if detailsPos: (newPosX, newPosZ) = detailsPos self.helpFrame.setPos(newPosX, 0, newPosZ)
def showDetails(self, cell, detailsPos, detailsHeight, event = None): self.notify.debug('Item showDetails') if self.manager.heldItem and self.manager.locked and cell.isEmpty() and self.isEmpty() or not (self.itemTuple): self.notify.debug(' early exit') return None inv = localAvatar.getInventory() if not inv: return None itemId = self.getId() self.helpFrame = DirectFrame(parent = self.manager, relief = None, state = DGG.DISABLED, sortOrder = 1) self.helpFrame.setBin('gui-popup', -5) detailGui = loader.loadModel('models/gui/gui_card_detail') topGui = loader.loadModel('models/gui/toplevel_gui') coinImage = topGui.find('**/treasure_w_coin*') self.SkillIcons = loader.loadModel('models/textureCards/skillIcons') self.BuffIcons = loader.loadModel('models/textureCards/buff_icons') border = self.SkillIcons.find('**/base') halfWidth = 0.29999999999999999 halfHeight = 0.20000000000000001 basePosX = cell.getX(aspect2d) basePosZ = cell.getZ(aspect2d) cellSizeX = 0.0 cellSizeZ = 0.0 if cell: cellSizeX = cell.cellSizeX cellSizeZ = cell.cellSizeZ textScale = PiratesGuiGlobals.TextScaleMed titleScale = PiratesGuiGlobals.TextScaleTitleSmall if len(self.getName()) >= 30: titleNameScale = PiratesGuiGlobals.TextScaleLarge else: titleNameScale = PiratesGuiGlobals.TextScaleExtraLarge subtitleScale = PiratesGuiGlobals.TextScaleMed iconScalar = 1.5 borderScaler = 0.25 splitHeight = 0.01 vMargin = 0.029999999999999999 runningVertPosition = 0.29999999999999999 runningSize = 0.0 labels = [] titleColor = PiratesGuiGlobals.TextFG6 rarity = ItemGlobals.getRarity(itemId) rarityText = PLocalizer.getItemRarityName(rarity) subtypeText = PLocalizer.getItemSubtypeName(ItemGlobals.getSubtype(itemId)) if rarity == ItemGlobals.CRUDE: titleColor = PiratesGuiGlobals.TextFG24 elif rarity == ItemGlobals.COMMON: titleColor = PiratesGuiGlobals.TextFG13 elif rarity == ItemGlobals.RARE: titleColor = PiratesGuiGlobals.TextFG4 elif rarity == ItemGlobals.FAMED: titleColor = PiratesGuiGlobals.TextFG5 titleLabel = DirectLabel(parent = self, relief = None, text = self.getName(), text_scale = titleNameScale, text_fg = titleColor, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) self.bg.setColor(titleColor) tHeight = 0.070000000000000007 titleLabel.setZ(runningVertPosition) runningVertPosition -= tHeight runningSize += tHeight labels.append(titleLabel) subtitleLabel = DirectLabel(parent = self, relief = None, text = '\x001slant\x001%s %s\x002' % (rarityText, subtypeText), text_scale = subtitleScale, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) subtHeight = 0.050000000000000003 subtitleLabel.setZ(subtHeight * 0.5 + runningVertPosition) runningVertPosition -= subtHeight runningSize += subtHeight labels.append(subtitleLabel) itemType = ItemGlobals.getType(itemId) itemSubtype = ItemGlobals.getSubtype(itemId) model = ItemGlobals.getModel(itemId) if model: self.realItem = loader.loadModel('models/inventory/' + model) if self.realItem: posHpr = ItemGlobals.getModelPosHpr(model) if posHpr: self.realItem.setPos(posHpr[0], posHpr[1], posHpr[2]) self.realItem.setHpr(posHpr[3], posHpr[4], posHpr[5]) elif itemSubtype == ItemGlobals.RAM: self.realItem.setPos(-1.5, 1.5, -0.59999999999999998) self.realItem.setHpr(70, 160, -90) else: self.realItem.setPos(0.0, 1.5, -0.059999999999999998) self.realItem.setHpr(0, 90, 0) self.realItem.reparentTo(self.portraitSceneGraph) iHeight = 0.17999999999999999 self.createBuffer() self.itemCard.setZ(runningVertPosition - 0.059999999999999998) runningVertPosition -= iHeight runningSize += iHeight labels.append(self.itemCard) itemCost = int(ItemGlobals.getGoldCost(itemId)) if self.cell and self.cell.container: itemCost = int(itemCost * self.cell.container.getItemPriceMult()) goldLabel = DirectLabel(parent = self, relief = None, image = coinImage, image_scale = 0.12, image_pos = Vec3(0.025000000000000001, 0, -0.02), text = str(itemCost), text_scale = subtitleScale, text_align = TextNode.ARight, text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, pos = (halfWidth - 0.050000000000000003, 0.0, runningVertPosition + 0.080000000000000002), text_pos = (0.0, -textScale)) labels.append(goldLabel) specialAttack = ItemGlobals.getSpecialAttack(itemId) if specialAttack: attackIcon = self.SkillIcons.find('**/%s' % WeaponGlobals.getSkillIcon(specialAttack)) specialAttackNameLabel = DirectLabel(parent = self, relief = None, image = border, image_scale = 0.10000000000000001, geom = attackIcon, geom_scale = 0.10000000000000001, image_pos = (-0.070000000000000007, 0.0, -0.050000000000000003), geom_pos = (-0.070000000000000007, 0.0, -0.050000000000000003), text = PLocalizer.getInventoryTypeName(specialAttack), text_scale = PiratesGuiGlobals.TextScaleLarge, text_wordwrap = halfWidth * 2.0 * (0.90000000000000002 / titleScale), text_align = TextNode.ALeft, text_fg = titleColor, text_font = PiratesGlobals.getInterfaceOutlineFont(), pos = (-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) specialAttackRankLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.ItemRank % ItemGlobals.getSpecialAttackRank(itemId), text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.90000000000000002 / titleScale), text_align = TextNode.ARight, pos = (halfWidth - textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) specialAttackType = WeaponGlobals.getSkillTrack(specialAttack) if specialAttackType == WeaponGlobals.BREAK_ATTACK_SKILL_INDEX: specialAttackTypeText = PLocalizer.BreakAttackSkill elif specialAttackType == WeaponGlobals.DEFENSE_SKILL_INDEX: specialAttackTypeText = PLocalizer.DefenseSkill else: specialAttackTypeText = PLocalizer.WeaponSkill specialAttackTypeLabel = DirectLabel(parent = self, relief = None, text = specialAttackTypeText, text_scale = PiratesGuiGlobals.TextScaleLarge, text_wordwrap = halfWidth * 2.7999999999999998 * (0.90000000000000002 / titleScale), text_align = TextNode.ALeft, pos = (-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition - PiratesGuiGlobals.TextScaleLarge), text_pos = (0.0, -textScale)) specialAttackInfo = PLocalizer.SkillDescriptions.get(specialAttack) specialAttackDescriptionText = specialAttackInfo[1] specialAttackDescriptionLabel = DirectLabel(parent = self, relief = None, text = specialAttackDescriptionText, text_scale = textScale, text_wordwrap = halfWidth * 2.7999999999999998 * (0.90000000000000002 / titleScale), text_align = TextNode.ALeft, pos = (-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition - specialAttackNameLabel.getHeight() + specialAttackTypeLabel.getHeight() - 0.059999999999999998), text_pos = (0.0, -textScale)) saHeight = specialAttackNameLabel.getHeight() + specialAttackTypeLabel.getHeight() + specialAttackDescriptionLabel.getHeight() - 0.040000000000000001 runningVertPosition -= saHeight runningSize += saHeight labels.append(specialAttackNameLabel) labels.append(specialAttackRankLabel) labels.append(specialAttackTypeLabel) labels.append(specialAttackDescriptionLabel) attributes = ItemGlobals.getAttributes(itemId) for i in range(0, len(attributes)): attributeIcon = self.SkillIcons.find('**/%s' % ItemGlobals.getAttributeIcon(attributes[i][0])) if not attributeIcon: attributeIcon = self.BuffIcons.find('**/%s' % ItemGlobals.getAttributeIcon(attributes[i][0])) attributeNameLabel = DirectLabel(parent = self, relief = None, image = border, image_scale = 0.050000000000000003, geom = attributeIcon, geom_scale = 0.050000000000000003, image_pos = (-0.070000000000000007, 0.0, -0.029999999999999999), geom_pos = (-0.070000000000000007, 0.0, -0.029999999999999999), text = PLocalizer.getItemAttributeName(attributes[i][0]), text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.90000000000000002 / titleScale), text_align = TextNode.ALeft, text_fg = titleColor, text_font = PiratesGlobals.getInterfaceOutlineFont(), pos = (-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) attributeRankLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.ItemRank % attributes[i][1], text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.90000000000000002 / titleScale), text_align = TextNode.ARight, pos = (halfWidth - textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) if attributeNameLabel.getHeight() > 0.074999999999999997: attributeNameSpace = 0.080000000000000002 else: attributeNameSpace = PiratesGuiGlobals.TextScaleLarge attributeDescriptionLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.getItemAttributeDescription(attributes[i][0]), text_scale = textScale, text_wordwrap = halfWidth * 2.7999999999999998 * (0.90000000000000002 / titleScale), text_align = TextNode.ALeft, pos = (-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition - attributeNameSpace), text_pos = (0.0, -textScale)) aHeight = attributeNameLabel.getHeight() + attributeDescriptionLabel.getHeight() runningVertPosition -= aHeight + splitHeight runningSize += aHeight + splitHeight labels.append(attributeNameLabel) labels.append(attributeRankLabel) labels.append(attributeDescriptionLabel) skillBoosts = ItemGlobals.getSkillBoosts(itemId) for i in range(0, len(skillBoosts)): boostIcon = self.SkillIcons.find('**/%s' % WeaponGlobals.getSkillIcon(skillBoosts[i][0])) boostNameLabel = DirectLabel(parent = self, relief = None, image = border, image_scale = 0.050000000000000003, geom = boostIcon, geom_scale = 0.050000000000000003, image_pos = (-0.070000000000000007, 0.0, -0.029999999999999999), geom_pos = (-0.070000000000000007, 0.0, -0.029999999999999999), text = PLocalizer.ItemBoost % PLocalizer.getInventoryTypeName(skillBoosts[i][0]), text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.90000000000000002 / titleScale), text_align = TextNode.ALeft, pos = (-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) boostRankLabel = DirectLabel(parent = self, relief = None, text = '+%s' % str(skillBoosts[i][1]), text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.90000000000000002 / titleScale), text_align = TextNode.ARight, pos = (halfWidth - textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) bHeight = boostNameLabel.getHeight() runningVertPosition -= bHeight + splitHeight runningSize += bHeight + splitHeight labels.append(boostNameLabel) labels.append(boostRankLabel) description = PLocalizer.getItemFlavorText(itemId) if description != '': descriptionLabel = DirectLabel(parent = self, relief = None, text = description, text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.94999999999999996 / textScale), text_align = TextNode.ALeft, pos = (-halfWidth + textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) dHeight = descriptionLabel.getHeight() + 0.02 runningVertPosition -= dHeight runningSize += dHeight labels.append(descriptionLabel) weaponLevel = 0 weaponRepId = WeaponGlobals.getRepId(itemId) weaponRep = inv.getReputation(weaponRepId) weaponReq = ItemGlobals.getWeaponRequirement(itemId) weaponText = None if weaponReq: weaponLevel = ReputationGlobals.getLevelFromTotalReputation(weaponRepId, weaponRep)[0] if weaponLevel < weaponReq: weaponColor = PiratesGuiGlobals.TextFG6 else: weaponColor = (0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1.0) weaponText = PLocalizer.ItemLevelRequirement % (weaponReq, PLocalizer.getItemTypeName(itemType)) else: trainingToken = EconomyGlobals.getItemTrainingReq(itemId) trainingAmt = inv.getItemQuantity(trainingToken) if trainingAmt == 0: weaponColor = PiratesGuiGlobals.TextFG6 weaponText = PLocalizer.ItemTrainingRequirement % PLocalizer.getItemTypeName(itemType) if weaponText: weaponReqLabel = DirectLabel(parent = self, relief = None, text = weaponText, text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (1.5 / titleScale), text_fg = weaponColor, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) wHeight = weaponReqLabel.getHeight() runningVertPosition -= wHeight runningSize += wHeight labels.append(weaponReqLabel) if not Freebooter.getPaidStatus(localAvatar.getDoId()): if rarity != ItemGlobals.CRUDE: unlimitedLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.UnlimitedAccessRequirement, text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (1.5 / titleScale), text_fg = PiratesGuiGlobals.TextFG6, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) uHeight = unlimitedLabel.getHeight() runningVertPosition -= uHeight runningSize += uHeight labels.append(unlimitedLabel) runningVertPosition -= 0.02 runningSize += 0.02 panels = self.helpFrame.attachNewNode('panels') topPanel = panels.attachNewNode('middlePanel') detailGui.find('**/top_panel').copyTo(topPanel) topPanel.setScale(0.080000000000000002) topPanel.reparentTo(self.helpFrame) middlePanel = panels.attachNewNode('middlePanel') detailGui.find('**/middle_panel').copyTo(middlePanel) middlePanel.setScale(0.080000000000000002) middlePanel.reparentTo(self.helpFrame) placement = 0 i = 0 heightMax = -0.080000000000000002 currentHeight = runningVertPosition while currentHeight < heightMax: middlePanel = panels.attachNewNode('middlePanel%s' % 1) detailGui.find('**/middle_panel').copyTo(middlePanel) middlePanel.setScale(0.080000000000000002) middlePanel.reparentTo(self.helpFrame) if currentHeight + 0.20000000000000001 >= heightMax: difference = heightMax - currentHeight placement += (0.16800000000000001 / 0.20000000000000001) * difference currentHeight += difference else: placement += 0.16800000000000001 currentHeight += 0.20000000000000001 middlePanel.setZ(-placement) i += 1 bottomPanel = panels.attachNewNode('bottomPanel') detailGui.find('**/bottom_panel').copyTo(bottomPanel) bottomPanel.setScale(0.080000000000000002) bottomPanel.setZ(-placement) bottomPanel.reparentTo(self.helpFrame) colorPanel = panels.attachNewNode('colorPanel') detailGui.find('**/color').copyTo(colorPanel) colorPanel.setScale(0.080000000000000002) colorPanel.setColor(titleColor) colorPanel.reparentTo(self.helpFrame) lineBreakTopPanel = panels.attachNewNode('lineBreakTopPanel') detailGui.find('**/line_break_top').copyTo(lineBreakTopPanel) lineBreakTopPanel.setScale(0.080000000000000002, 0.080000000000000002, 0.070000000000000007) lineBreakTopPanel.setZ(0.0080000000000000002) lineBreakTopPanel.reparentTo(self.helpFrame) panels.flattenStrong() self.helpFrame['frameSize'] = (-halfWidth, halfWidth, -(runningSize + vMargin), vMargin) totalHeight = self.helpFrame.getHeight() - 0.10000000000000001 for label in labels: label.reparentTo(self.helpFrame) if basePosX > 0.0: newPosX = basePosX - halfWidth + cellSizeX * 0.45000000000000001 else: newPosX = basePosX + halfWidth + cellSizeX * 0.45000000000000001 if basePosZ > 0.0: newPosZ = basePosZ + cellSizeZ * 0.45000000000000001 else: newPosZ = basePosZ + totalHeight - cellSizeZ * 0.75 if detailsPos: (newPosX, newPosZ) = detailsPos self.helpFrame.setPos(newPosX, 0, newPosZ)
def createHelpFrame(self, args = None): if self.helpFrame: return None inv = localAvatar.getInventory() if not inv: return None baseRank = max(self.skillRank, 1) lvlDamageMod = WeaponGlobals.getLevelDamageModifier(localAvatar.getLevel()) buff = WeaponGlobals.getSkillEffectFlag(self.skillId) dur = WeaponGlobals.getAttackDuration(self.skillId) effect = dur + dur * (baseRank - 1) / 4.0 bonus = localAvatar.getSkillRankBonus(self.skillId) upgradeAmt = WeaponGlobals.getAttackUpgrade(self.skillId) rank = localAvatar.getSkillRank(self.skillId) skillBoost = 0 if self.skillId in ItemGlobals.getLinkedSkills(localAvatar.currentWeaponId): linkedSkillId = WeaponGlobals.getLinkedSkillId(self.skillId) skillBoost = ItemGlobals.getWeaponBoosts(localAvatar.currentWeaponId, linkedSkillId) skillBoost += ItemGlobals.getWeaponBoosts(localAvatar.getCurrentCharm(), linkedSkillId) else: skillBoost = ItemGlobals.getWeaponBoosts(localAvatar.currentWeaponId, self.skillId) skillBoost += ItemGlobals.getWeaponBoosts(localAvatar.getCurrentCharm(), self.skillId) manaCost = 0 if WeaponGlobals.getSkillTrack(self.skillId) != WeaponGlobals.PASSIVE_SKILL_INDEX: manaCost = WeaponGlobals.getMojoCost(self.skillId) if manaCost < 0: amt = localAvatar.getSkillRankBonus(InventoryType.StaffConservation) manaCost = min(manaCost - manaCost * amt, 1.0) damage = 0 loDamage = 0 mpDamage = 0 mpLoDamage = 0 if WeaponGlobals.getSkillTrack(self.skillId) == WeaponGlobals.TONIC_SKILL_INDEX: damage = WeaponGlobals.getAttackSelfHP(self.skillId) elif WeaponGlobals.getSkillTrack(self.skillId) != WeaponGlobals.PASSIVE_SKILL_INDEX: mod = (1.0 + bonus) * lvlDamageMod damage = int(WeaponGlobals.getAttackTargetHP(self.skillId) * mod) loDamage = damage / 2 mpDamage = int(WeaponGlobals.getAttackTargetMojo(self.skillId) * mod) mpLoDamage = mpDamage / 2 try: skillInfo = PLocalizer.SkillDescriptions.get(self.skillId) skillTitle = PLocalizer.makeHeadingString(PLocalizer.InventoryTypeNames.get(self.skillId), 2) skillType = PLocalizer.makeHeadingString(skillInfo[0], 1) except: self.notify.error('Error getting skill info for skillId %s' % self.skillId) description = skillInfo[1] if damage < 0: description += ' ' + PLocalizer.DealsDamage elif damage > 0: if loDamage: loDamage = 0 description += ' ' + PLocalizer.HealsDamageRange else: description += ' ' + PLocalizer.HealsDamage if mpDamage < 0: description += ' ' + PLocalizer.DealsMpDamage effectId = WeaponGlobals.getSkillEffectFlag(self.skillId) if effectId: description += ' ' + SkillEffectDescriptions.get(effectId)[0] if bonus: if self.skillId == InventoryType.SailBroadsideLeft or self.skillId == InventoryType.SailBroadsideRight: description += ' ' + PLocalizer.BroadsideDesc if self.skillId == InventoryType.CannonShoot: description += ' ' + PLocalizer.CannonShootDesc if self.skillId == InventoryType.DollAttune: description += ' ' + PLocalizer.MultiAttuneDesc if WeaponGlobals.getSkillInterrupt(self.skillId): description += ' ' + PLocalizer.InterruptDesc if WeaponGlobals.getSkillUnattune(self.skillId): description += ' ' + PLocalizer.UnattuneDesc upgradeInfo = '' if self.showUpgrade and rank < 5: if rank > 0: upgradeInfo = skillInfo[2] if upgradeInfo == '': if damage < 0: upgradeInfo += PLocalizer.UpgradesDamage elif damage > 0: upgradeInfo += PLocalizer.UpgradesHealing if mpDamage < 0: upgradeInfo += ' ' + PLocalizer.UpgradesMpDamage if effectId: entry = SkillEffectDescriptions.get(effectId) if len(entry) > 1: if not damage: upgradeInfo += PLocalizer.UpgradesDuration else: upgradeInfo += ' ' + PLocalizer.And upgradeInfo += ' ' + entry[1] upgradeInfo += '!' elif len(upgradeInfo) >= 4: upgradeInfo = skillInfo[3] else: upgradeInfo = PLocalizer.ClickToLearn elif not self.showIcon: unlockLevel = RepChart.getSkillUnlockLevel(self.skillId) if unlockLevel > 0: upgradeInfo = PLocalizer.UnlocksAtLevel % unlockLevel if self.skillId in SkillComboReq and SkillComboReq[self.skillId] and inv.getStackQuantity(self.skillId - 1) < 2: color = 'red' if rank == 0: color = 'red' upgradeInfo = '' description += '\n' + color + SkillComboReq[self.skillId] + '.' skillDesc = skillTitle + '\n' + skillType + '\n\n' + description + '\ngreen' + upgradeInfo stats = [] if manaCost: stats.append(abs(manaCost)) if damage and loDamage: stats.append(abs(loDamage)) stats.append(abs(damage)) elif damage: stats.append(abs(damage)) if mpDamage: stats.append(abs(mpLoDamage)) stats.append(abs(mpDamage)) if buff == WeaponGlobals.C_CURSE: stats.append(WeaponGlobals.CURSED_DAM_AMP * 100) if buff == WeaponGlobals.C_WEAKEN: stats.append(WeaponGlobals.WEAKEN_PENALTY * 100) if effect > 0: stats.append(effect) if skillInfo[4]: if bonus == 0 and upgradeAmt > 0: if not self.skillId == InventoryType.SailBroadsideLeft and self.skillId == InventoryType.SailBroadsideRight: pass if not (self.skillId == InventoryType.CannonShoot): bonus = upgradeAmt if upgradeAmt < 1.0 and upgradeAmt > 0: bonus *= 100 if self.skillId == InventoryType.SailTreasureSense: bonus /= 2.0 elif self.skillId == InventoryType.CutlassParry: bonus += WeaponGlobals.getSubtypeParryBonus(localAvatar.currentWeaponId) if bonus: stats.append(abs(bonus)) if self.skillId == InventoryType.DollAttune: stats.append(rank) if self.skillRank: rankText = DirectFrame(parent = self, relief = None, text = PLocalizer.makeHeadingString(PLocalizer.Rank + ' %s' % (self.skillRank + skillBoost), 2), text_align = TextNode.ARight, text_scale = PiratesGuiGlobals.TextScaleSmall, text_fg = PiratesGuiGlobals.TextFG2, text_wordwrap = 15, text_shadow = (0, 0, 0, 1), pos = (0.45000000000000001, 0, 0), textMayChange = 1, sortOrder = 92, state = DGG.DISABLED) stats = [stat + 0.01 for stat in stats] try: pass except TypeError: self.notify.error('Error formatting skillDesc(%s): %s' % (self.skillId, stats)) helpText = DirectFrame(parent = self, relief = None, text = skillDesc % stats, text_align = TextNode.ALeft, text_scale = PiratesGuiGlobals.TextScaleSmall, text_fg = PiratesGuiGlobals.TextFG2, text_wordwrap = 17, textMayChange = 1, state = DGG.DISABLED, sortOrder = 91) height = -(helpText.getHeight() + 0.01) if self.lock: height = height - 0.040000000000000001 width = 0.55000000000000004 self.helpFrame = BorderFrame(parent = self, state = DGG.DISABLED, frameSize = (-0.040000000000000001, width, height, 0.050000000000000003), pos = (0, 0, -0.12), sortOrder = 90) self.helpFrame.setBin('gui-popup', 0) helpText.reparentTo(self.helpFrame) if self.skillRank: rankText.reparentTo(self.helpFrame) if self.lock: self.lockedFrame = DirectFrame(parent = self.helpFrame, relief = None, pos = (0.087999999999999995, 0, height + 0.029999999999999999), image = SkillButton.SubLock, image_scale = 0.13, image_pos = (-0.055, 0, 0.012999999999999999), text = PLocalizer.VR_AuthAccess, text_scale = PiratesGuiGlobals.TextScaleSmall, text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG13) self.notify.debug('locked!') pos = self.helpFrame.getPos(aspect2d) x = min(pos[0], base.a2dRight - width) z = max(pos[2], base.a2dBottom - height) self.helpFrame.setPos(aspect2d, x, 0, z)
def useTargetedSkill(self, skillId, ammoSkillId, skillResult, targetId, areaIdList, attackerEffects, targetEffects, areaIdEffects, itemEffects, timestamp, pos, charge=0, localSignal=0): if WeaponGlobals.isSelfUseSkill(skillId) and not localSignal: selfUse = True else: selfUse = False if localSignal: target = self.cr.doId2do.get(targetId) if target and target != self and WeaponGlobals.isBreakAttackComboSkill( skillId) and skillResult == WeaponGlobals.RESULT_HIT: levelGrade = self.cr.battleMgr.getModifiedExperienceGrade( self, target) self.guiMgr.combatTray.updateSkillCharges(levelGrade) if not self.isLocal() and localSignal and WeaponGlobals.getSkillTrack( skillId) == WeaponGlobals.DEFENSE_SKILL_INDEX or selfUse: multiHits = [] numHits = WeaponGlobals.getNumHits(skillId) hitTiming = WeaponGlobals.getMultiHitAttacks(skillId) if hitTiming: multiHits += hitTiming if ammoSkillId: numHits += WeaponGlobals.getNumHits(ammoSkillId) - 1 hitTiming = WeaponGlobals.getMultiHitAttacks(ammoSkillId) if hitTiming: multiHits += hitTiming if not selfUse or self.isNpc: if not targetId and areaIdList: self.playSkillMovie(skillId, ammoSkillId, skillResult, charge, areaIdList[0], areaIdList) else: self.playSkillMovie(skillId, ammoSkillId, skillResult, charge, targetId, areaIdList) if skillResult == WeaponGlobals.RESULT_REFLECTED or selfUse: target = self targetId = self.getDoId() elif skillResult == WeaponGlobals.RESULT_BLOCKED: target = None else: target = self.currentTarget if target and targetId: if multiHits and numHits: multiHitEffects = self.packMultiHitEffects( targetEffects, numHits) for i in range(numHits): target.targetedWeaponHit(skillId, ammoSkillId, skillResult, multiHitEffects[i], self, pos, charge, multiHits[i], i, itemEffects=itemEffects) else: target.targetedWeaponHit(skillId, ammoSkillId, skillResult, targetEffects, self, pos, charge, itemEffects=itemEffects) for (targetId, areaEffects) in zip(areaIdList, areaIdEffects): target = self.cr.doId2do.get(targetId) if target: if multiHits and numHits: multiHitEffects = self.packMultiHitEffects( areaEffects, numHits) for i in range(numHits): target.targetedWeaponHit(skillId, ammoSkillId, skillResult, multiHitEffects[i], self, pos, charge, multiHits[i], i, itemEffects=itemEffects) else: target.targetedWeaponHit(skillId, ammoSkillId, skillResult, areaEffects, self, pos, charge, itemEffects=itemEffects) if not (self.currentTarget) and not areaIdList: self.playHitSound(skillId, ammoSkillId, WeaponGlobals.RESULT_MISS)
def createHelpbox(self, args = None): if self.helpFrame: return None itemType = EconomyGlobals.getItemType(self.data[0]) if itemType <= ItemType.WAND or itemType == ItemType.POTION: itemId = self.data[0] self.helpFrame = DirectFrame(parent = aspect2d, relief = None, state = DGG.DISABLED, sortOrder = 1) detailGui = loader.loadModel('models/gui/gui_card_detail') topGui = loader.loadModel('models/gui/toplevel_gui') coinImage = topGui.find('**/treasure_w_coin*') self.SkillIcons = loader.loadModel('models/textureCards/skillIcons') self.BuffIcons = loader.loadModel('models/textureCards/buff_icons') border = self.SkillIcons.find('**/base') halfWidth = 0.29999999999999999 halfHeight = 0.20000000000000001 textScale = PiratesGuiGlobals.TextScaleMed titleScale = PiratesGuiGlobals.TextScaleTitleSmall titleNameScale = PiratesGuiGlobals.TextScaleExtraLarge subtitleScale = PiratesGuiGlobals.TextScaleMed iconScalar = 1.5 borderScaler = 0.25 splitHeight = 0.01 vMargin = 0.029999999999999999 runningVertPosition = 0.29999999999999999 runningSize = 0.0 labels = [] titleColor = PiratesGuiGlobals.TextFG6 itemColor = 'itemRed' rarity = ItemGlobals.getRarity(itemId) rarityText = PLocalizer.getItemRarityName(rarity) subtypeText = PLocalizer.getItemSubtypeName(ItemGlobals.getSubtype(itemId)) if rarity == ItemGlobals.CRUDE: titleColor = PiratesGuiGlobals.TextFG24 itemColor = 'itemBrown' elif rarity == ItemGlobals.COMMON: titleColor = PiratesGuiGlobals.TextFG13 itemColor = 'itemYellow' elif rarity == ItemGlobals.RARE: titleColor = PiratesGuiGlobals.TextFG4 itemColor = 'itemGreen' elif rarity == ItemGlobals.FAMED: titleColor = PiratesGuiGlobals.TextFG5 itemColor = 'itemBlue' titleLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.getItemName(itemId), text_scale = titleNameScale, text_fg = titleColor, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) self.bg.setColor(titleColor) tHeight = 0.070000000000000007 titleLabel.setZ(runningVertPosition) runningVertPosition -= tHeight runningSize += tHeight labels.append(titleLabel) subtitleLabel = DirectLabel(parent = self, relief = None, text = '\x01slant\x01%s %s\x02' % (rarityText, subtypeText), text_scale = subtitleScale, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) subtHeight = 0.050000000000000003 subtitleLabel.setZ(subtHeight * 0.5 + runningVertPosition) runningVertPosition -= subtHeight runningSize += subtHeight labels.append(subtitleLabel) itemType = ItemGlobals.getType(itemId) itemSubtype = ItemGlobals.getSubtype(itemId) model = ItemGlobals.getModel(itemId) if model: if itemType == ItemGlobals.GRENADE: self.realItem = loader.loadModel('models/ammunition/' + model) elif itemType == ItemGlobals.POTION: self.realItem = loader.loadModel('models/inventory/' + model) else: self.realItem = loader.loadModel('models/handheld/' + model) if self.realItem: spinBlur = self.realItem.find('**/motion_blur') if spinBlur: spinBlur.hide() if itemSubtype == ItemGlobals.MUSKET: bayonetPart = self.realItem.find('**/bayonet') if bayonetPart: bayonetPart.stash() posHpr = ItemGlobals.getModelPosHpr(model) if posHpr: self.realItem.setPos(posHpr[0], posHpr[1], posHpr[2]) self.realItem.setHpr(posHpr[3], posHpr[4], posHpr[5]) elif itemType == ItemGlobals.SWORD: self.realItem.setPos(-1.5, 3.0, -0.29999999999999999) self.realItem.setHpr(90, 170, -90) elif itemSubtype in (ItemGlobals.MUSKET, ItemGlobals.BAYONET): self.realItem.setPos(-1.2, 3.0, -0.10000000000000001) self.realItem.setHpr(0, 135, 10) elif itemSubtype == ItemGlobals.BLUNDERBUSS: self.realItem.setPos(-0.29999999999999999, 2.0, 0.0) self.realItem.setHpr(0, 90, 0) elif itemType == ItemGlobals.GUN: self.realItem.setPos(-0.5, 2.0, -0.20000000000000001) self.realItem.setHpr(0, 90, 0) elif itemType == ItemGlobals.DOLL: self.realItem.setPos(0.0, 1.8999999999999999, -0.10000000000000001) self.realItem.setHpr(0, 90, 180) elif itemType == ItemGlobals.DAGGER: self.realItem.setPos(-1.0, 2.0, -0.29999999999999999) self.realItem.setHpr(90, 170, -90) elif itemType == ItemGlobals.GRENADE: self.realItem.setPos(0.0, 3.5, -0.20000000000000001) self.realItem.setHpr(0, 0, 0) elif itemType == ItemGlobals.STAFF: self.realItem.setPos(-0.40000000000000002, 3.0, -0.29999999999999999) self.realItem.setHpr(-90, 15, -90) elif itemSubtype == ItemGlobals.RAM: self.realItem.setPos(-1.5, 1.5, -0.59999999999999998) self.realItem.setHpr(70, 160, -90) elif itemType == ItemGlobals.POTION: self.realItem.setPos(0.0, 2.5, -0.40000000000000002) self.realItem.setHpr(45, 0, 0) else: self.realItem.setPos(0.0, 1.5, -0.059999999999999998) self.realItem.setHpr(0, 90, 0) self.realItem.reparentTo(self.portraitSceneGraph) iHeight = 0.17499999999999999 self.createBuffer() self.itemCard.setZ(runningVertPosition - 0.059999999999999998) runningVertPosition -= iHeight runningSize += iHeight labels.append(self.itemCard) goldLabel = DirectLabel(parent = self, relief = None, image = coinImage, image_scale = 0.12, image_pos = Vec3(0.025000000000000001, 0, -0.02), text = str(int(ItemGlobals.getGoldCost(itemId) * ItemGlobals.GOLD_SALE_MULTIPLIER)), text_scale = subtitleScale, text_align = TextNode.ARight, text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, pos = (halfWidth - 0.050000000000000003, 0.0, runningVertPosition + 0.080000000000000002), text_pos = (0.0, -textScale)) labels.append(goldLabel) infoText = PLocalizer.ItemAttackStrength % '\x01%s\x01%s\x02' % (itemColor, ItemGlobals.getPower(itemId)) if itemType == ItemGlobals.GUN: infoText += ' %s' % PLocalizer.ItemBarrels % '\x01%s\x01%s\x02' % (itemColor, ItemGlobals.getBarrels(itemId)) infoText += ' %s' % PLocalizer.ItemRangeStrength % '\x01%s\x01%s\x02' % (itemColor, PLocalizer.getItemRangeName(WeaponGlobals.getRange(itemId))) if itemType != ItemGlobals.POTION: infoLabel = DirectLabel(parent = self, relief = None, text = infoText, text_scale = textScale, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) iHeight = 0.080000000000000002 runningVertPosition -= iHeight runningSize += iHeight labels.append(infoLabel) specialAttack = None if itemType != ItemGlobals.POTION: specialAttack = ItemGlobals.getSpecialAttack(itemId) if specialAttack: attackIcon = self.SkillIcons.find('**/%s' % WeaponGlobals.getSkillIcon(specialAttack)) specialAttackNameLabel = DirectLabel(parent = self, relief = None, image = border, image_scale = 0.10000000000000001, geom = attackIcon, geom_scale = 0.10000000000000001, image_pos = (-0.070000000000000007, 0.0, -0.050000000000000003), geom_pos = (-0.070000000000000007, 0.0, -0.050000000000000003), text = PLocalizer.getInventoryTypeName(specialAttack), text_scale = PiratesGuiGlobals.TextScaleLarge, text_wordwrap = halfWidth * 2.0 * (0.90000000000000002 / titleScale), text_align = TextNode.ALeft, text_fg = titleColor, text_font = PiratesGlobals.getInterfaceOutlineFont(), text_shadow = PiratesGuiGlobals.TextShadow, pos = (-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) specialAttackRankLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.ItemRank % ItemGlobals.getSpecialAttackRank(itemId), text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.90000000000000002 / titleScale), text_align = TextNode.ARight, pos = (halfWidth - textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) specialAttackType = WeaponGlobals.getSkillTrack(specialAttack) if specialAttackType == WeaponGlobals.BREAK_ATTACK_SKILL_INDEX: specialAttackTypeText = PLocalizer.BreakAttackSkill elif specialAttackType == WeaponGlobals.DEFENSE_SKILL_INDEX: specialAttackTypeText = PLocalizer.DefenseSkill else: specialAttackTypeText = PLocalizer.WeaponSkill specialAttackTypeLabel = DirectLabel(parent = self, relief = None, text = specialAttackTypeText, text_scale = 0.033500000000000002, text_wordwrap = halfWidth * 2.7999999999999998 * (0.90000000000000002 / titleScale), text_align = TextNode.ALeft, pos = (-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition - PiratesGuiGlobals.TextScaleLarge), text_pos = (0.0, -textScale)) specialAttackInfo = PLocalizer.SkillDescriptions.get(specialAttack) specialAttackDescriptionText = specialAttackInfo[1] specialAttackDescriptionLabel = DirectLabel(parent = self, relief = None, text = specialAttackDescriptionText, text_scale = textScale, text_wordwrap = halfWidth * 2.7999999999999998 * (0.90000000000000002 / titleScale), text_align = TextNode.ALeft, pos = (-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition - specialAttackNameLabel.getHeight() + specialAttackTypeLabel.getHeight() - 0.059999999999999998), text_pos = (0.0, -textScale)) saHeight = specialAttackNameLabel.getHeight() + specialAttackTypeLabel.getHeight() + specialAttackDescriptionLabel.getHeight() - 0.040000000000000001 runningVertPosition -= saHeight runningSize += saHeight labels.append(specialAttackNameLabel) labels.append(specialAttackRankLabel) labels.append(specialAttackTypeLabel) labels.append(specialAttackDescriptionLabel) attributes = ItemGlobals.getAttributes(itemId) for i in range(0, len(attributes)): attributeIcon = self.SkillIcons.find('**/%s' % ItemGlobals.getAttributeIcon(attributes[i][0])) if not attributeIcon: attributeIcon = self.BuffIcons.find('**/%s' % ItemGlobals.getAttributeIcon(attributes[i][0])) attributeNameLabel = DirectLabel(parent = self, relief = None, image = border, image_scale = 0.050000000000000003, geom = attributeIcon, geom_scale = 0.050000000000000003, image_pos = (-0.070000000000000007, 0.0, -0.029999999999999999), geom_pos = (-0.070000000000000007, 0.0, -0.029999999999999999), text = PLocalizer.getItemAttributeName(attributes[i][0]), text_scale = PiratesGuiGlobals.TextScaleLarge, text_wordwrap = halfWidth * 2.0 * (0.90000000000000002 / titleScale), text_align = TextNode.ALeft, text_fg = titleColor, text_font = PiratesGlobals.getInterfaceOutlineFont(), text_shadow = PiratesGuiGlobals.TextShadow, pos = (-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) attributeRankLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.ItemRank % attributes[i][1], text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.90000000000000002 / titleScale), text_align = TextNode.ARight, pos = (halfWidth - textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) if attributeNameLabel.getHeight() > 0.074999999999999997: attributeNameSpace = 0.080000000000000002 else: attributeNameSpace = PiratesGuiGlobals.TextScaleLarge attributeDescriptionLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.getItemAttributeDescription(attributes[i][0]), text_scale = textScale, text_wordwrap = halfWidth * 2.7999999999999998 * (0.90000000000000002 / titleScale), text_align = TextNode.ALeft, pos = (-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition - attributeNameSpace), text_pos = (0.0, -textScale)) aHeight = attributeNameLabel.getHeight() + attributeDescriptionLabel.getHeight() runningVertPosition -= aHeight + splitHeight runningSize += aHeight + splitHeight labels.append(attributeNameLabel) labels.append(attributeRankLabel) labels.append(attributeDescriptionLabel) skillBoosts = ItemGlobals.getSkillBoosts(itemId) for i in range(0, len(skillBoosts)): boostIcon = self.SkillIcons.find('**/%s' % WeaponGlobals.getSkillIcon(skillBoosts[i][0])) boostNameLabel = DirectLabel(parent = self, relief = None, image = border, image_scale = 0.050000000000000003, geom = boostIcon, geom_scale = 0.050000000000000003, image_pos = (-0.070000000000000007, 0.0, -0.029999999999999999), geom_pos = (-0.070000000000000007, 0.0, -0.029999999999999999), text = PLocalizer.ItemBoost % PLocalizer.getInventoryTypeName(skillBoosts[i][0]), text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.90000000000000002 / titleScale), text_align = TextNode.ALeft, pos = (-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) boostRankLabel = DirectLabel(parent = self, relief = None, text = '+%s' % str(skillBoosts[i][1]), text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.90000000000000002 / titleScale), text_align = TextNode.ARight, pos = (halfWidth - textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) bHeight = boostNameLabel.getHeight() runningVertPosition -= bHeight + splitHeight runningSize += bHeight + splitHeight labels.append(boostNameLabel) labels.append(boostRankLabel) description = PLocalizer.getItemFlavorText(itemId) if description != '': descriptionLabel = DirectLabel(parent = self, relief = None, text = description, text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (0.94999999999999996 / textScale), text_align = TextNode.ALeft, pos = (-halfWidth + textScale * 0.5, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) dHeight = descriptionLabel.getHeight() + 0.02 runningVertPosition -= dHeight runningSize += dHeight labels.append(descriptionLabel) inv = localAvatar.getInventory() weaponLevel = 0 weaponRepId = WeaponGlobals.getRepId(itemId) weaponRep = inv.getReputation(weaponRepId) weaponReq = ItemGlobals.getWeaponRequirement(itemId) weaponText = None trainingToken = EconomyGlobals.getItemTrainingReq(itemId) trainingAmt = inv.getItemQuantity(trainingToken) if weaponReq: weaponLevel = ReputationGlobals.getLevelFromTotalReputation(weaponRepId, weaponRep)[0] if weaponLevel < weaponReq: weaponColor = PiratesGuiGlobals.TextFG6 else: weaponColor = (0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1.0) weaponText = PLocalizer.ItemLevelRequirement % (weaponReq, PLocalizer.getItemTypeName(itemType)) elif trainingAmt == 0: weaponColor = PiratesGuiGlobals.TextFG6 weaponText = PLocalizer.ItemTrainingRequirement % PLocalizer.getItemTypeName(itemType) if trainingAmt == 0: if itemType == ItemGlobals.GUN: base.localAvatar.sendRequestContext(InventoryType.GunTrainingRequired) elif itemType == ItemGlobals.DOLL: base.localAvatar.sendRequestContext(InventoryType.DollTrainingRequired) elif itemType == ItemGlobals.DAGGER: base.localAvatar.sendRequestContext(InventoryType.DaggerTrainingRequired) elif itemType == ItemGlobals.STAFF: base.localAvatar.sendRequestContext(InventoryType.StaffTrainingRequired) if weaponText: weaponReqLabel = DirectLabel(parent = self, relief = None, text = weaponText, text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (1.5 / titleScale), text_fg = weaponColor, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) wHeight = weaponReqLabel.getHeight() runningVertPosition -= wHeight runningSize += wHeight labels.append(weaponReqLabel) if not Freebooter.getPaidStatus(localAvatar.getDoId()): if rarity != ItemGlobals.CRUDE: unlimitedLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.UnlimitedAccessRequirement, text_scale = textScale, text_wordwrap = halfWidth * 2.0 * (1.5 / titleScale), text_fg = PiratesGuiGlobals.TextFG6, text_shadow = PiratesGuiGlobals.TextShadow, text_align = TextNode.ACenter, pos = (0.0, 0.0, runningVertPosition), text_pos = (0.0, -textScale)) uHeight = unlimitedLabel.getHeight() runningVertPosition -= uHeight runningSize += uHeight labels.append(unlimitedLabel) runningVertPosition -= 0.02 runningSize += 0.02 panels = self.helpFrame.attachNewNode('panels') topPanel = panels.attachNewNode('middlePanel') detailGui.find('**/top_panel').copyTo(topPanel) topPanel.setScale(0.080000000000000002) topPanel.reparentTo(self.helpFrame) middlePanel = panels.attachNewNode('middlePanel') detailGui.find('**/middle_panel').copyTo(middlePanel) middlePanel.setScale(0.080000000000000002) middlePanel.reparentTo(self.helpFrame) placement = 0 i = 0 heightMax = -0.080000000000000002 currentHeight = runningVertPosition while currentHeight < heightMax: middlePanel = panels.attachNewNode('middlePanel%s' % 1) detailGui.find('**/middle_panel').copyTo(middlePanel) middlePanel.setScale(0.080000000000000002) middlePanel.reparentTo(self.helpFrame) if currentHeight + 0.20000000000000001 >= heightMax: difference = heightMax - currentHeight placement += (0.16800000000000001 / 0.20000000000000001) * difference currentHeight += difference else: placement += 0.16800000000000001 currentHeight += 0.20000000000000001 middlePanel.setZ(-placement) i += 1 bottomPanel = panels.attachNewNode('bottomPanel') detailGui.find('**/bottom_panel').copyTo(bottomPanel) bottomPanel.setScale(0.080000000000000002) bottomPanel.setZ(-placement) bottomPanel.reparentTo(self.helpFrame) colorPanel = panels.attachNewNode('colorPanel') detailGui.find('**/color').copyTo(colorPanel) colorPanel.setScale(0.080000000000000002) colorPanel.setColor(titleColor) colorPanel.reparentTo(self.helpFrame) lineBreakTopPanel = panels.attachNewNode('lineBreakTopPanel') detailGui.find('**/line_break_top').copyTo(lineBreakTopPanel) lineBreakTopPanel.setScale(0.080000000000000002, 0.080000000000000002, 0.070000000000000007) lineBreakTopPanel.setZ(0.0080000000000000002) lineBreakTopPanel.reparentTo(self.helpFrame) if itemType != ItemGlobals.POTION: lineBreakBottomPanel = panels.attachNewNode('lineBreakBottomPanel') detailGui.find('**/line_break_bottom').copyTo(lineBreakBottomPanel) lineBreakBottomPanel.setScale(0.080000000000000002, 0.080000000000000002, 0.070000000000000007) lineBreakBottomPanel.setZ(-0.014999999999999999) lineBreakBottomPanel.reparentTo(self.helpFrame) panels.flattenStrong() self.helpFrame['frameSize'] = (-halfWidth, halfWidth, -(runningSize + vMargin), vMargin) totalHeight = self.helpFrame.getHeight() - 0.10000000000000001 for label in labels: label.reparentTo(self.helpFrame) self.helpFrame.setBin('gui-popup', 0) self.helpFrame.setPos(self, 0.55000000000000004, 0, -0.29999999999999999) zOffset = -0.5 - self.helpFrame.getPos(aspect2d)[2] if zOffset >= 0.0: self.helpFrame.setPos(self, 0.55000000000000004, 0, zOffset - 0.29999999999999999) else: weaponInfo = PLocalizer.WeaponDescriptions.get(self.data[0]) weaponDesc = weaponInfo self.helpText = DirectFrame(parent = self, relief = None, text = weaponDesc, state = DGG.DISABLED, text_align = TextNode.ALeft, text_scale = PiratesGuiGlobals.TextScaleSmall, text_fg = PiratesGuiGlobals.TextFG2, text_wordwrap = 13, textMayChange = 0, sortOrder = 91) height = -self.helpText.getHeight() self.helpFrame = BorderFrame(parent = aspect2d, state = DGG.DISABLED, frameSize = (-0.029999999999999999, 0.42999999999999999, height, 0.050000000000000003), sortOrder = 90, borderScale = 0.20000000000000001) self.helpText.reparentTo(self.helpFrame) self.helpFrame.setBin('gui-popup', 0) self.helpFrame.setPos(self, 0.25, 0, -0.035000000000000003)
def showDetails(self, cell, detailsPos, detailsHeight, event=None): self.notify.debug('Item showDetails') if self.manager.heldItem or self.manager.locked or cell.isEmpty( ) or self.isEmpty() or not self.itemTuple: self.notify.debug(' early exit') return inv = localAvatar.getInventory() if not inv: return itemId = self.getId() self.helpFrame = DirectFrame(parent=self.manager, relief=None, state=DGG.DISABLED, sortOrder=1) self.helpFrame.setBin('gui-popup', -5) detailGui = loader.loadModel('models/gui/gui_card_detail') topGui = loader.loadModel('models/gui/toplevel_gui') coinImage = topGui.find('**/treasure_w_coin*') self.SkillIcons = loader.loadModel('models/textureCards/skillIcons') self.BuffIcons = loader.loadModel('models/textureCards/buff_icons') border = self.SkillIcons.find('**/base') halfWidth = 0.3 halfHeight = 0.2 basePosX = cell.getX(aspect2d) basePosZ = cell.getZ(aspect2d) cellSizeX = 0.0 cellSizeZ = 0.0 if cell: cellSizeX = cell.cellSizeX cellSizeZ = cell.cellSizeZ textScale = PiratesGuiGlobals.TextScaleMed titleScale = PiratesGuiGlobals.TextScaleTitleSmall if len(self.getName()) >= 30: titleNameScale = PiratesGuiGlobals.TextScaleLarge else: titleNameScale = PiratesGuiGlobals.TextScaleExtraLarge subtitleScale = PiratesGuiGlobals.TextScaleMed iconScalar = 1.5 borderScaler = 0.25 splitHeight = 0.01 vMargin = 0.03 runningVertPosition = 0.3 runningSize = 0.0 labels = [] titleColor = PiratesGuiGlobals.TextFG6 itemColor = 'itemRed' rarity = ItemGlobals.getRarity(itemId) rarityText = PLocalizer.getItemRarityName(rarity) subtypeText = PLocalizer.getItemSubtypeName( ItemGlobals.getSubtype(itemId)) if rarity == ItemGlobals.CRUDE: titleColor = PiratesGuiGlobals.TextFG24 itemColor = 'itemBrown' else: if rarity == ItemGlobals.COMMON: titleColor = PiratesGuiGlobals.TextFG13 itemColor = 'itemYellow' else: if rarity == ItemGlobals.RARE: titleColor = PiratesGuiGlobals.TextFG4 itemColor = 'itemGreen' else: if rarity == ItemGlobals.FAMED: titleColor = PiratesGuiGlobals.TextFG5 itemColor = 'itemBlue' titleLabel = DirectLabel(parent=self, relief=None, text=self.getName(), text_scale=titleNameScale, text_fg=titleColor, text_shadow=PiratesGuiGlobals.TextShadow, text_align=TextNode.ACenter, pos=(0.0, 0.0, runningVertPosition), text_pos=(0.0, -textScale)) self.bg.setColor(titleColor) tHeight = 0.07 titleLabel.setZ(runningVertPosition) runningVertPosition -= tHeight runningSize += tHeight labels.append(titleLabel) subtitleLabel = DirectLabel(parent=self, relief=None, text='\x01slant\x01%s %s\x02' % (rarityText, subtypeText), text_scale=subtitleScale, text_fg=PiratesGuiGlobals.TextFG2, text_shadow=PiratesGuiGlobals.TextShadow, text_align=TextNode.ACenter, pos=(0.0, 0.0, runningVertPosition), text_pos=(0.0, -textScale)) subtHeight = 0.05 subtitleLabel.setZ(subtHeight * 0.5 + runningVertPosition) runningVertPosition -= subtHeight runningSize += subtHeight labels.append(subtitleLabel) itemType = ItemGlobals.getType(itemId) itemSubtype = ItemGlobals.getSubtype(itemId) model = ItemGlobals.getModel(itemId) if model: if itemType == ItemGlobals.GRENADE: self.realItem = loader.loadModel('models/ammunition/' + model) else: self.realItem = loader.loadModel('models/handheld/' + model) if self.realItem: spinBlur = self.realItem.find('**/motion_blur') if spinBlur: spinBlur.hide() if itemSubtype == ItemGlobals.MUSKET: bayonetPart = self.realItem.find('**/bayonet') if bayonetPart: bayonetPart.stash() posHpr = ItemGlobals.getModelPosHpr(model) if posHpr: self.realItem.setPos(posHpr[0], posHpr[1], posHpr[2]) self.realItem.setHpr(posHpr[3], posHpr[4], posHpr[5]) else: if itemType == ItemGlobals.SWORD: self.realItem.setPos(-1.5, 3.0, -0.3) self.realItem.setHpr(90, 170, -90) else: if itemSubtype in (ItemGlobals.MUSKET, ItemGlobals.BAYONET): self.realItem.setPos(-1.2, 3.0, -0.1) self.realItem.setHpr(0, 135, 10) else: if itemSubtype == ItemGlobals.BLUNDERBUSS: self.realItem.setPos(-0.3, 2.0, 0.0) self.realItem.setHpr(0, 90, 0) else: if itemType == ItemGlobals.GUN: self.realItem.setPos(-0.5, 2.0, -0.2) self.realItem.setHpr(0, 90, 0) else: if itemType == ItemGlobals.DOLL: self.realItem.setPos(0.0, 1.9, -0.1) self.realItem.setHpr(0, 90, 180) else: if itemType == ItemGlobals.DAGGER: self.realItem.setPos( -1.0, 2.0, -0.3) self.realItem.setHpr(90, 170, -90) else: if itemType == ItemGlobals.GRENADE: self.realItem.setPos( 0.0, 3.5, -0.2) self.realItem.setHpr(0, 0, 0) else: if itemType == ItemGlobals.STAFF: self.realItem.setPos( -0.4, 3.0, -0.3) self.realItem.setHpr( -90, 15, -90) self.realItem.reparentTo(self.portraitSceneGraph) iHeight = 0.175 self.createBuffer() self.itemCard.setZ(runningVertPosition - 0.06) runningVertPosition -= iHeight runningSize += iHeight labels.append(self.itemCard) itemCost = int(ItemGlobals.getGoldCost(itemId)) if self.cell: if self.cell.container: itemCost = int(itemCost * self.cell.container.getItemPriceMult()) goldLabel = DirectLabel(parent=self, relief=None, image=coinImage, image_scale=0.12, image_pos=Vec3(0.025, 0, -0.02), text=str(itemCost), text_scale=subtitleScale, text_align=TextNode.ARight, text_fg=PiratesGuiGlobals.TextFG1, text_shadow=PiratesGuiGlobals.TextShadow, pos=(halfWidth - 0.05, 0.0, runningVertPosition + 0.08), text_pos=(0.0, -textScale)) labels.append(goldLabel) infoText = PLocalizer.ItemAttackStrength % ( '\x01%s\x01%s\x02' % (itemColor, ItemGlobals.getPower(itemId))) if itemType == ItemGlobals.GUN: infoText += ' %s' % ( PLocalizer.ItemBarrels % ('\x01%s\x01%s\x02' % (itemColor, ItemGlobals.getBarrels(itemId)))) infoText += ' %s' % ( PLocalizer.ItemRangeStrength % ('\x01%s\x01%s\x02' % (itemColor, PLocalizer.getItemRangeName( WeaponGlobals.getRange(itemId))))) infoLabel = DirectLabel(parent=self, relief=None, text=infoText, text_scale=textScale, text_align=TextNode.ACenter, pos=(0.0, 0.0, runningVertPosition), text_pos=(0.0, -textScale)) iHeight = 0.08 runningVertPosition -= iHeight runningSize += iHeight labels.append(infoLabel) specialAttack = ItemGlobals.getSpecialAttack(itemId) if specialAttack: attackIcon = self.SkillIcons.find( '**/%s' % WeaponGlobals.getSkillIcon(specialAttack)) specialAttackNameLabel = DirectLabel( parent=self, relief=None, image=border, image_scale=0.1, geom=attackIcon, geom_scale=0.1, image_pos=(-0.07, 0.0, -0.05), geom_pos=(-0.07, 0.0, -0.05), text=PLocalizer.getInventoryTypeName(specialAttack), text_scale=PiratesGuiGlobals.TextScaleLarge, text_wordwrap=halfWidth * 2.0 * (0.9 / titleScale), text_align=TextNode.ALeft, text_fg=titleColor, text_font=PiratesGlobals.getInterfaceOutlineFont(), text_shadow=PiratesGuiGlobals.TextShadow, pos=(-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition), text_pos=(0.0, -textScale)) specialAttackRankLabel = DirectLabel( parent=self, relief=None, text=PLocalizer.ItemRank % ItemGlobals.getSpecialAttackRank(itemId), text_scale=textScale, text_wordwrap=halfWidth * 2.0 * (0.9 / titleScale), text_align=TextNode.ARight, pos=(halfWidth - textScale * 0.5, 0.0, runningVertPosition), text_pos=(0.0, -textScale)) specialAttackType = WeaponGlobals.getSkillTrack(specialAttack) if specialAttackType == WeaponGlobals.BREAK_ATTACK_SKILL_INDEX: specialAttackTypeText = PLocalizer.BreakAttackSkill else: if specialAttackType == WeaponGlobals.DEFENSE_SKILL_INDEX: specialAttackTypeText = PLocalizer.DefenseSkill else: specialAttackTypeText = PLocalizer.WeaponSkill specialAttackTypeLabel = DirectLabel( parent=self, relief=None, text=specialAttackTypeText, text_scale=0.0335, text_wordwrap=halfWidth * 2.8 * (0.9 / titleScale), text_align=TextNode.ALeft, pos=(-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition - PiratesGuiGlobals.TextScaleLarge), text_pos=(0.0, -textScale)) specialAttackInfo = PLocalizer.SkillDescriptions.get( specialAttack) specialAttackDescriptionText = specialAttackInfo[1] specialAttackDescriptionLabel = DirectLabel( parent=self, relief=None, text=specialAttackDescriptionText, text_scale=textScale, text_wordwrap=halfWidth * 2.8 * (0.9 / titleScale), text_align=TextNode.ALeft, pos=(-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition - (specialAttackNameLabel.getHeight() + specialAttackTypeLabel.getHeight() - 0.06)), text_pos=(0.0, -textScale)) saHeight = specialAttackNameLabel.getHeight( ) + specialAttackTypeLabel.getHeight( ) + specialAttackDescriptionLabel.getHeight() - 0.04 runningVertPosition -= saHeight runningSize += saHeight labels.append(specialAttackNameLabel) labels.append(specialAttackRankLabel) labels.append(specialAttackTypeLabel) labels.append(specialAttackDescriptionLabel) attributes = ItemGlobals.getAttributes(itemId) for i in range(0, len(attributes)): attributeIcon = self.SkillIcons.find( '**/%s' % ItemGlobals.getAttributeIcon(attributes[i][0])) if not attributeIcon: attributeIcon = self.BuffIcons.find( '**/%s' % ItemGlobals.getAttributeIcon(attributes[i][0])) attributeNameLabel = DirectLabel( parent=self, relief=None, image=border, image_scale=0.05, geom=attributeIcon, geom_scale=0.05, image_pos=(-0.07, 0.0, -0.03), geom_pos=(-0.07, 0.0, -0.03), text=PLocalizer.getItemAttributeName(attributes[i][0]), text_scale=PiratesGuiGlobals.TextScaleLarge, text_wordwrap=halfWidth * 2.0 * (0.9 / titleScale), text_align=TextNode.ALeft, text_fg=titleColor, text_font=PiratesGlobals.getInterfaceOutlineFont(), text_shadow=PiratesGuiGlobals.TextShadow, pos=(-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition), text_pos=(0.0, -textScale)) attributeRankLabel = DirectLabel( parent=self, relief=None, text=PLocalizer.ItemRank % attributes[i][1], text_scale=textScale, text_wordwrap=halfWidth * 2.0 * (0.9 / titleScale), text_align=TextNode.ARight, pos=(halfWidth - textScale * 0.5, 0.0, runningVertPosition), text_pos=(0.0, -textScale)) if attributeNameLabel.getHeight() > 0.075: attributeNameSpace = 0.08 else: attributeNameSpace = PiratesGuiGlobals.TextScaleLarge attributeDescriptionLabel = DirectLabel( parent=self, relief=None, text=PLocalizer.getItemAttributeDescription( attributes[i][0]), text_scale=textScale, text_wordwrap=halfWidth * 2.8 * (0.9 / titleScale), text_align=TextNode.ALeft, pos=(-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition - attributeNameSpace), text_pos=(0.0, -textScale)) aHeight = attributeNameLabel.getHeight( ) + attributeDescriptionLabel.getHeight() runningVertPosition -= aHeight + splitHeight runningSize += aHeight + splitHeight labels.append(attributeNameLabel) labels.append(attributeRankLabel) labels.append(attributeDescriptionLabel) skillBoosts = ItemGlobals.getSkillBoosts(itemId) for i in range(0, len(skillBoosts)): skillId, skillBoost = skillBoosts[i] linkedSkills = ItemGlobals.getLinkedSkills(itemId) if linkedSkills: for id in linkedSkills: if skillId == WeaponGlobals.getLinkedSkillId(id): skillId = id boostIcon = self.SkillIcons.find( '**/%s' % WeaponGlobals.getSkillIcon(skillId)) boostNameLabel = DirectLabel( parent=self, relief=None, image=border, image_scale=0.05, geom=boostIcon, geom_scale=0.05, image_pos=(-0.07, 0.0, -0.03), geom_pos=(-0.07, 0.0, -0.03), text=PLocalizer.ItemBoost % PLocalizer.getInventoryTypeName(skillId), text_scale=textScale, text_wordwrap=halfWidth * 2.0 * (0.9 / titleScale), text_align=TextNode.ALeft, pos=(-halfWidth + 0.12 + textScale * 0.5, 0.0, runningVertPosition), text_pos=(0.0, -textScale)) boostRankLabel = DirectLabel( parent=self, relief=None, text='+%s' % str(skillBoost), text_scale=textScale, text_wordwrap=halfWidth * 2.0 * (0.9 / titleScale), text_align=TextNode.ARight, pos=(halfWidth - textScale * 0.5, 0.0, runningVertPosition), text_pos=(0.0, -textScale)) bHeight = boostNameLabel.getHeight() runningVertPosition -= bHeight + splitHeight runningSize += bHeight + splitHeight labels.append(boostNameLabel) labels.append(boostRankLabel) description = PLocalizer.getItemFlavorText(itemId) if description != '': descriptionLabel = DirectLabel( parent=self, relief=None, text=description, text_scale=textScale, text_wordwrap=halfWidth * 2.0 * (0.95 / textScale), text_align=TextNode.ALeft, pos=(-halfWidth + textScale * 0.5, 0.0, runningVertPosition), text_pos=(0.0, -textScale)) dHeight = descriptionLabel.getHeight() + 0.02 runningVertPosition -= dHeight runningSize += dHeight labels.append(descriptionLabel) weaponLevel = 0 weaponRepId = WeaponGlobals.getRepId(itemId) weaponRep = inv.getReputation(weaponRepId) weaponReq = ItemGlobals.getWeaponRequirement(itemId) weaponText = None trainingToken = EconomyGlobals.getItemTrainingReq(itemId) trainingAmt = inv.getItemQuantity(trainingToken) if weaponReq: weaponLevel = ReputationGlobals.getLevelFromTotalReputation( weaponRepId, weaponRep)[0] if weaponLevel < weaponReq: weaponColor = PiratesGuiGlobals.TextFG6 else: weaponColor = (0.4, 0.4, 0.4, 1.0) weaponText = PLocalizer.ItemLevelRequirement % ( weaponReq, PLocalizer.getItemTypeName(itemType)) else: if trainingAmt == 0: weaponColor = PiratesGuiGlobals.TextFG6 weaponText = PLocalizer.ItemTrainingRequirement % PLocalizer.getItemTypeName( itemType) if trainingAmt == 0: if itemType == ItemGlobals.GUN: base.localAvatar.sendRequestContext( InventoryType.GunTrainingRequired) elif itemType == ItemGlobals.DOLL: base.localAvatar.sendRequestContext( InventoryType.DollTrainingRequired) elif itemType == ItemGlobals.DAGGER: base.localAvatar.sendRequestContext( InventoryType.DaggerTrainingRequired) elif itemType == ItemGlobals.STAFF: base.localAvatar.sendRequestContext( InventoryType.StaffTrainingRequired) if weaponText: weaponReqLabel = DirectLabel( parent=self, relief=None, text=weaponText, text_scale=textScale, text_wordwrap=halfWidth * 2.0 * (1.5 / titleScale), text_fg=weaponColor, text_shadow=PiratesGuiGlobals.TextShadow, text_align=TextNode.ACenter, pos=(0.0, 0.0, runningVertPosition), text_pos=(0.0, -textScale)) wHeight = weaponReqLabel.getHeight() runningVertPosition -= wHeight runningSize += wHeight labels.append(weaponReqLabel) if not Freebooter.getPaidStatus(localAvatar.getDoId()): if rarity != ItemGlobals.CRUDE: unlimitedLabel = DirectLabel( parent=self, relief=None, text=PLocalizer.UnlimitedAccessRequirement, text_scale=textScale, text_wordwrap=halfWidth * 2.0 * (1.5 / titleScale), text_fg=PiratesGuiGlobals.TextFG6, text_shadow=PiratesGuiGlobals.TextShadow, text_align=TextNode.ACenter, pos=(0.0, 0.0, runningVertPosition), text_pos=(0.0, -textScale)) uHeight = unlimitedLabel.getHeight() runningVertPosition -= uHeight runningSize += uHeight labels.append(unlimitedLabel) runningVertPosition -= 0.02 runningSize += 0.02 panels = self.helpFrame.attachNewNode('panels') topPanel = panels.attachNewNode('middlePanel') detailGui.find('**/top_panel').copyTo(topPanel) topPanel.setScale(0.08) topPanel.reparentTo(self.helpFrame) middlePanel = panels.attachNewNode('middlePanel') detailGui.find('**/middle_panel').copyTo(middlePanel) middlePanel.setScale(0.08) middlePanel.reparentTo(self.helpFrame) placement = 0 i = 0 heightMax = -0.08 currentHeight = runningVertPosition if detailsHeight: currentHeight = -detailsHeight while currentHeight < heightMax: middlePanel = panels.attachNewNode('middlePanel%s' % 1) detailGui.find('**/middle_panel').copyTo(middlePanel) middlePanel.setScale(0.08) middlePanel.reparentTo(self.helpFrame) if currentHeight + 0.2 >= heightMax: difference = heightMax - currentHeight placement += 0.168 / 0.2 * difference currentHeight += difference else: placement += 0.168 currentHeight += 0.2 middlePanel.setZ(-placement) i += 1 bottomPanel = panels.attachNewNode('bottomPanel') detailGui.find('**/bottom_panel').copyTo(bottomPanel) bottomPanel.setScale(0.08) bottomPanel.setZ(-placement) bottomPanel.reparentTo(self.helpFrame) colorPanel = panels.attachNewNode('colorPanel') detailGui.find('**/color').copyTo(colorPanel) colorPanel.setScale(0.08) colorPanel.setColor(titleColor) colorPanel.reparentTo(self.helpFrame) lineBreakTopPanel = panels.attachNewNode('lineBreakTopPanel') detailGui.find('**/line_break_top').copyTo(lineBreakTopPanel) lineBreakTopPanel.setScale(0.08, 0.08, 0.07) lineBreakTopPanel.setZ(0.008) lineBreakTopPanel.reparentTo(self.helpFrame) lineBreakBottomPanel = panels.attachNewNode('lineBreakBottomPanel') detailGui.find('**/line_break_bottom').copyTo(lineBreakBottomPanel) lineBreakBottomPanel.setScale(0.08, 0.08, 0.07) lineBreakBottomPanel.setZ(-0.015) lineBreakBottomPanel.reparentTo(self.helpFrame) panels.flattenStrong() self.helpFrame['frameSize'] = (-halfWidth, halfWidth, -(runningSize + vMargin), vMargin) totalHeight = self.helpFrame.getHeight() - 0.1 for label in labels: label.reparentTo(self.helpFrame) if basePosX > 0.0: newPosX = basePosX - (halfWidth + cellSizeX * 0.45) else: newPosX = basePosX + (halfWidth + cellSizeX * 0.45) newPosZ = basePosZ > 0.0 and basePosZ + cellSizeZ * 0.45 else: newPosZ = basePosZ + totalHeight - cellSizeZ * 0.75 if detailsPos: newPosX, newPosZ = detailsPos self.helpFrame.setPos(newPosX, 0, newPosZ) return
def FindSkills(repId, skilltrack, minlvl): inv = base.localAvatar.getInventory() if inv == None: print 'WARNING - FindSkills came up with no inventory for ', repId return [] choices = [] if repId == InventoryType.FishingRep: skillId = InventoryType.begin_WeaponSkillFishingRod while skillId < InventoryType.end_WeaponSkillFishingRod: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: if inv.getStackQuantity(skillId) >= minlvl: choices.append(skillId) skillId += 1 if repId == InventoryType.CutlassRep: skillId = InventoryType.begin_WeaponSkillCutlass while skillId < InventoryType.end_WeaponSkillCutlass: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: if inv.getStackQuantity(skillId) >= minlvl: choices.append(skillId) skillId += 1 elif repId == InventoryType.MeleeRep: skillId = InventoryType.begin_WeaponSkillMelee while skillId < InventoryType.end_WeaponSkillMelee: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: if inv.getStackQuantity(skillId) >= minlvl: choices.append(skillId) skillId += 1 elif repId == InventoryType.DaggerRep: skillId = InventoryType.begin_WeaponSkillDagger while skillId < InventoryType.end_WeaponSkillDagger: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: if inv.getStackQuantity(skillId) >= minlvl: choices.append(skillId) skillId += 1 elif repId == InventoryType.GrenadeRep: skillId = InventoryType.begin_WeaponSkillGrenade while skillId < InventoryType.end_WeaponSkillGrenade: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: if inv.getStackQuantity(skillId) >= minlvl: choices.append(skillId) skillId += 1 elif repId == InventoryType.DollRep: skillId = InventoryType.begin_WeaponSkillDoll while skillId < InventoryType.end_WeaponSkillDoll: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: if inv.getStackQuantity(skillId) >= minlvl: choices.append(skillId) skillId += 1 elif repId == InventoryType.WandRep: skillId = InventoryType.begin_WeaponSkillWand while skillId < InventoryType.end_WeaponSkillWand: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: if inv.getStackQuantity(skillId) >= minlvl: choices.append(skillId) skillId += 1 elif repId == InventoryType.KettleRep: skillId = InventoryType.begin_WeaponSkillKettle while skillId < InventoryType.end_WeaponSkillKettle: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: if inv.getStackQuantity(skillId) >= minlvl: choices.append(skillId) skillId += 1 elif repId == InventoryType.PistolRep: skillId = InventoryType.begin_WeaponSkillPistol while skillId < InventoryType.end_WeaponSkillPistol: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: if inv.getStackQuantity(skillId) >= minlvl: choices.append(skillId) skillId += 1 elif repId == InventoryType.CannonRep: skillId = InventoryType.begin_WeaponSkillCannon while skillId < InventoryType.end_WeaponSkillCannon: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: if inv.getStackQuantity(skillId) >= minlvl: choices.append(skillId) skillId += 1 elif repId == InventoryType.SailingRep: skillId = InventoryType.begin_SkillSailing while skillId < InventoryType.end_SkillSailing: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: if inv.getStackQuantity(skillId) >= minlvl: choices.append(skillId) skillId += 1 elif repId == InventoryType.DefenseCannonRep: for skillId in PiratesGlobals.CANNON_DEFENSE_SKILLS: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: if inv.getStackQuantity(skillId) >= minlvl: choices.append(skillId) skillId += 1 return choices
def getAllSkills(repId, skilltrack, wantWeaponSkill = 0): inv = base.localAvatar.getInventory() if inv == None: print 'WARNING - getAllSkills came up with no inventory for ', repId return [] minlvl = 2 choices = [] if repId == InventoryType.CutlassRep: skillId = InventoryType.begin_WeaponSkillCutlass while skillId < InventoryType.end_WeaponSkillCutlass: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: locked = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): locked = not WeaponGlobals.canFreeUse(skillId) if inv.getStackQuantity(skillId) >= minlvl: skill = (skillId, True, locked) else: skill = (skillId, False, locked) choices.append(skill) skillId += 1 elif repId == InventoryType.MeleeRep: skillId = InventoryType.begin_WeaponSkillMelee while skillId < InventoryType.end_WeaponSkillMelee: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: locked = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): locked = not WeaponGlobals.canFreeUse(skillId) if inv.getStackQuantity(skillId) >= minlvl: skill = (skillId, True, locked) else: skill = (skillId, False, locked) choices.append(skill) skillId += 1 elif repId == InventoryType.DaggerRep: skillId = InventoryType.begin_WeaponSkillDagger while skillId < InventoryType.end_WeaponSkillDagger: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: locked = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): locked = not WeaponGlobals.canFreeUse(skillId) if inv.getStackQuantity(skillId) >= minlvl: skill = (skillId, True, locked) else: skill = (skillId, False, locked) choices.append(skill) skillId += 1 elif repId == InventoryType.GrenadeRep: skillId = InventoryType.begin_WeaponSkillGrenade while skillId < InventoryType.end_WeaponSkillGrenade: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: locked = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): locked = not WeaponGlobals.canFreeUse(skillId) if inv.getStackQuantity(skillId) >= minlvl: skill = (skillId, True, locked) else: skill = (skillId, False, locked) choices.append(skill) skillId += 1 elif repId == InventoryType.DollRep: skillId = InventoryType.begin_WeaponSkillDoll while skillId < InventoryType.end_WeaponSkillDoll: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: locked = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): locked = not WeaponGlobals.canFreeUse(skillId) if inv.getStackQuantity(skillId) >= minlvl: skill = (skillId, True, locked) else: skill = (skillId, False, locked) choices.append(skill) skillId += 1 elif repId == InventoryType.WandRep: skillId = InventoryType.begin_WeaponSkillWand while skillId < InventoryType.end_WeaponSkillWand: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: locked = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): locked = not WeaponGlobals.canFreeUse(skillId) if inv.getStackQuantity(skillId) >= minlvl: skill = (skillId, True, locked) else: skill = (skillId, False, locked) choices.append(skill) skillId += 1 elif repId == InventoryType.KettleRep: skillId = InventoryType.begin_WeaponSkillKettle while skillId < InventoryType.end_WeaponSkillKettle: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: locked = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): locked = not WeaponGlobals.canFreeUse(skillId) if inv.getStackQuantity(skillId) >= minlvl: skill = (skillId, True, locked) else: skill = (skillId, False, locked) choices.append(skill) skillId += 1 elif repId == InventoryType.PistolRep: skillId = InventoryType.begin_WeaponSkillPistol while skillId < InventoryType.end_WeaponSkillPistol: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: locked = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): locked = not WeaponGlobals.canFreeUse(skillId) if inv.getStackQuantity(skillId) >= minlvl: skill = (skillId, True, locked) else: skill = (skillId, False, locked) choices.append(skill) skillId += 1 elif repId == InventoryType.CannonRep: wantWeaponSkill = 0 skillId = InventoryType.begin_WeaponSkillCannon while skillId < InventoryType.end_WeaponSkillCannon: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: locked = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): locked = not WeaponGlobals.canFreeUse(skillId) if inv.getStackQuantity(skillId) >= minlvl: skill = (skillId, True, locked) else: skill = (skillId, False, locked) choices.append(skill) skillId += 1 elif repId == InventoryType.SailingRep: skillId = InventoryType.begin_SkillSailing while skillId < InventoryType.end_SkillSailing: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: locked = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): locked = not WeaponGlobals.canFreeUse(skillId) shouldBeVisible = inv.getStackQuantity(skillId) >= minlvl skill = (skillId, shouldBeVisible, locked) choices.append(skill) skillId += 1 elif repId == InventoryType.DefenseCannonRep: wantWeaponSkill = 0 for skillId in PiratesGlobals.CANNON_DEFENSE_SKILLS: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: skill = (skillId, True, False) choices.append(skill) skillId += 1 elif repId == InventoryType.FishingRep: wantWeaponSkill = 0 skillId = InventoryType.begin_WeaponSkillFishingRod skilltrack = 1 while skillId < InventoryType.end_WeaponSkillFishingRod: if WeaponGlobals.getSkillTrack(skillId) == skilltrack: locked = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): locked = not WeaponGlobals.canFreeUse(skillId) if inv.getStackQuantity(skillId) >= minlvl: skill = (skillId, True, locked) else: skill = (skillId, False, locked) choices.append(skill) skillId += 1 if wantWeaponSkill: weaponSkill = getWeaponSkill(repId) if weaponSkill: choices.append((weaponSkill, True, 0)) return choices
def useTargetedSkill(self, skillId, ammoSkillId, skillResult, targetId, areaIdList, attackerEffects, targetEffects, areaIdEffects, itemEffects, timestamp, pos, charge = 0, localSignal = 0): if WeaponGlobals.isSelfUseSkill(skillId) and not localSignal: selfUse = True else: selfUse = False if localSignal: target = self.cr.doId2do.get(targetId) if target and target != self and WeaponGlobals.isBreakAttackComboSkill(skillId) and skillResult == WeaponGlobals.RESULT_HIT: levelGrade = self.cr.battleMgr.getModifiedExperienceGrade(self, target) self.guiMgr.combatTray.updateSkillCharges(levelGrade) if not self.isLocal() and localSignal and WeaponGlobals.getSkillTrack(skillId) == WeaponGlobals.DEFENSE_SKILL_INDEX or selfUse: multiHits = [] numHits = WeaponGlobals.getNumHits(skillId) hitTiming = WeaponGlobals.getMultiHitAttacks(skillId) if hitTiming: multiHits += hitTiming if ammoSkillId: numHits += WeaponGlobals.getNumHits(ammoSkillId) - 1 hitTiming = WeaponGlobals.getMultiHitAttacks(ammoSkillId) if hitTiming: multiHits += hitTiming if not selfUse or self.isNpc: if not targetId and areaIdList: self.playSkillMovie(skillId, ammoSkillId, skillResult, charge, areaIdList[0], areaIdList) else: self.playSkillMovie(skillId, ammoSkillId, skillResult, charge, targetId, areaIdList) if skillResult == WeaponGlobals.RESULT_REFLECTED or selfUse: target = self targetId = self.getDoId() elif skillResult == WeaponGlobals.RESULT_BLOCKED: target = None else: target = self.currentTarget if target and targetId: if multiHits and numHits: multiHitEffects = self.packMultiHitEffects(targetEffects, numHits) for i in range(numHits): target.targetedWeaponHit(skillId, ammoSkillId, skillResult, multiHitEffects[i], self, pos, charge, multiHits[i], i, itemEffects = itemEffects) else: target.targetedWeaponHit(skillId, ammoSkillId, skillResult, targetEffects, self, pos, charge, itemEffects = itemEffects) for (targetId, areaEffects) in zip(areaIdList, areaIdEffects): target = self.cr.doId2do.get(targetId) if target: if multiHits and numHits: multiHitEffects = self.packMultiHitEffects(areaEffects, numHits) for i in range(numHits): target.targetedWeaponHit(skillId, ammoSkillId, skillResult, multiHitEffects[i], self, pos, charge, multiHits[i], i, itemEffects = itemEffects) else: target.targetedWeaponHit(skillId, ammoSkillId, skillResult, areaEffects, self, pos, charge, itemEffects = itemEffects) if not (self.currentTarget) and not areaIdList: self.playHitSound(skillId, ammoSkillId, WeaponGlobals.RESULT_MISS)
def __init__(self, skillId, callback, quantity=0, skillRank=0, showQuantity=False, showHelp=False, showRing=False, hotkey=None, name='', showIcon=True, showLock=False, rechargeSkillId=False, isWeaponSkill=False, assocAmmo=[]): DirectFrame.__init__(self, parent=NodePath(), relief=None) self.initialiseoptions(SkillButton) gui = loader.loadModel('models/gui/toplevel_gui') if not SkillButton.SkillIcons: print 'not SkillButton.SkillIcons:' SkillButton.SkillIcons = loader.loadModel( 'models/textureCards/skillIcons') SkillButton.Image = (SkillButton.SkillIcons.find('**/base'), SkillButton.SkillIcons.find('**/base_down'), SkillButton.SkillIcons.find('**/base_over')) SkillButton.SkillRechargedSound = loadSfx( SoundGlobals.SFX_SKILL_RECHARGED) SkillButton.SubLock = gui.find('**/pir_t_gui_gen_key_subscriber') SkillButton.SpecialIcons = [] for entry in SPECIAL_SKILL_ICONS: if not entry: SkillButton.SpecialIcons.append(None) continue specialImage = (SkillButton.SkillIcons.find('**/%s' % entry), ) SkillButton.SpecialIcons.append(specialImage) model = loader.loadModel('models/effects/particleMaps') toggleIcon = model.find('**/particleGlow') toggleIcon.node().setAttrib( ColorBlendAttrib.make(ColorBlendAttrib.MAdd)) self.toggleFrame = DirectFrame(relief=None, state=DGG.DISABLED, parent=self, image=toggleIcon, image_scale=0.34999999999999998, image_pos=(0.0, 0.0, -0.01)) self.toggleFrame.hide() self.glowRing = None self.glowRing2 = None self.assocAmmo = assocAmmo self.skillId = skillId self.quantity = quantity self.showQuantity = showQuantity self.skillRank = skillRank self.skillRing = None self.callback = callback self.showUpgrade = False self.showHelp = showHelp self.showRing = showRing self.showIcon = showIcon self.showLock = showLock self.isWeaponSkill = isWeaponSkill self.lock = None self.name = name self.helpFrame = None self.quantityLabel = None self.skillButton = None self.hotkeyLabel = None self.hotkey = hotkey self.greyOut = 0 self.tonicId = 0 self.skillRingIval = None self.impulseIval = None self.quickImpulseIval = None self.isBreakAttackSkill = WeaponGlobals.getSkillTrack( self.skillId) == WeaponGlobals.BREAK_ATTACK_SKILL_INDEX self.isDefenseSkill = WeaponGlobals.getSkillTrack( self.skillId) == WeaponGlobals.DEFENSE_SKILL_INDEX self.rechargeFilled = 0 self.defenseAuraEffect = None if self.isWeaponSkill: self.weaponBackground = DirectLabel( parent=self, state=DGG.DISABLED, image=SkillButton.SkillIcons.find('**/box_base'), image_scale=(0.22, 0, 0.22), image_pos=(0.0, 0.0, 0.0)) self.weaponBackground.flattenLight() self.weaponBackground.setColor(0.20000000000000001, 0.20000000000000001, 0.20000000000000001, 0.20000000000000001) self.weaponBackground.setTransparency(1) if showRing: if self.isBreakAttackSkill: color = Vec4(1, 0, 0, 1) elif self.isDefenseSkill: color = Vec4(0, 1, 1, 1) else: color = Vec4(1, 0.80000000000000004, 0.5, 1) self.skillRing = SkillRing(color, Vec4(0, 0, 0, 1.0)) gs = self.skillRing.meterFaceHalf2.node().getGeomState(0) self.skillRing.meterFaceHalf2.node().setGeomState( 0, gs.removeAttrib(ColorAttrib.getClassType())) self.skillRing.reparentTo(self, 0) self.skillRing.setPos(0, 0, 0) self.updateSkillId(skillId) if showQuantity: self.updateQuantity(quantity) if hotkey: self.createHotkey(hotkey) if showLock: self.createLock() self.skillButton.bind(DGG.ENTER, self.showDetails) self.skillButton.bind(DGG.EXIT, self.hideDetails) if self.skillId >= InventoryType.begin_Consumables and self.skillId <= InventoryType.end_Consumables and not WeaponGlobals.getSkillEffectFlag( skillId): self.totalRechargeTime = base.cr.battleMgr.getModifiedRechargeTime( localAvatar, InventoryType.UseItem) self.tonicId = InventoryType.UseItem else: self.totalRechargeTime = base.cr.battleMgr.getModifiedRechargeTime( localAvatar, self.skillId) if showRing: if not self.isBreakAttackSkill: self.createSkillRingIval() if self.tonicId: timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging( InventoryType.UseItem) else: timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging( self.skillId) if self.isBreakAttackSkill and timeSpentRecharging < self.totalRechargeTime: self.updateRechargeRing() elif not (self.isBreakAttackSkill): if (self.totalRechargeTime or timeSpentRecharging ) and not (timeSpentRecharging > self.totalRechargeTime): self.skillRingIval.start(startT=timeSpentRecharging) not (timeSpentRecharging > self.totalRechargeTime) self.skillRing.meterFaceHalf1.setR(0) self.skillRing.meterFaceHalf2.setR(180) self.skillRing.meterFaceHalf1.setColor( self.skillRing.meterActiveColor, 100) self.skillRing.meterFaceHalf2.setColor( self.skillRing.meterActiveColor, 100) self.skillRing.meterFaceHalf1.show() self.skillRing.meterFaceHalf2.show() if not self.isBreakAttackSkill: self.checkAmount() if self.isDefenseSkill: self.startRecharge() if self.isWeaponSkill: self.weaponLabel = DirectLabel( parent=self, relief=None, text=PLocalizer.WeaponAbility, text_font=PiratesGlobals.getPirateBoldOutlineFont(), text_align=TextNode.ACenter, text_scale=PiratesGuiGlobals.TextScaleLarge, text_fg=PiratesGuiGlobals.TextFG2, text_shadow=PiratesGuiGlobals.TextShadow, textMayChange=0, pos=(0.0, 0, -0.12), sortOrder=70, state=DGG.DISABLED) self.weaponLabel.flattenLight()
def createHelpbox(self, args = None): if self.helpBox: return None baseRank = max(self.skillRank, 1) lvlDamageMod = WeaponGlobals.getLevelDamageModifier(localAvatar.getLevel()) buff = WeaponGlobals.getSkillEffectFlag(self.skillId) dur = WeaponGlobals.getAttackDuration(self.skillId) effect = dur + dur * (baseRank - 1) / 4 dodge = WeaponGlobals.getAttackDodge(self.skillId) * baseRank accuracy = 0 damageMod = 0 reduceDamMod = 0 rechargeMod = 0 shipTurningMod = 0 shipSpeedMod = 0 rangeMod = 0 treasureSenseMod = 0 manaCost = WeaponGlobals.getMojoCost(self.skillId) damage = 0 loDamage = 0 mpDamage = 0 chargeMod = 0 if self.skillId == InventoryType.SailBroadsideLeft or self.skillId == InventoryType.SailBroadsideRight: damageMod = WeaponGlobals.getAttackTargetHP(self.skillId) * (baseRank - 1) * 100 elif self.skillId == InventoryType.CannonShoot: rechargeMod = WeaponGlobals.CANNON_SHOOT_RATE_REDUCTION * (baseRank - 1) * 100 elif WeaponGlobals.getSkillTrack(self.skillId) == WeaponGlobals.TONIC_SKILL_INDEX: damage = WeaponGlobals.getAttackSelfHP(self.skillId) elif WeaponGlobals.getSkillTrack(self.skillId) != WeaponGlobals.PASSIVE_SKILL_INDEX: damage = int(WeaponGlobals.getAttackTargetHP(self.skillId) * (1.0 + WeaponGlobals.LEVELUP_DAMAGE_MULTIPLIER * (baseRank - 1))) * lvlDamageMod loDamage = damage / 2 mpDamage = int(WeaponGlobals.getAttackTargetMojo(self.skillId) * (1.0 + WeaponGlobals.LEVELUP_DAMAGE_MULTIPLIER * (baseRank - 1))) * lvlDamageMod mpLoDamage = mpDamage / 2 else: accuracy = WeaponGlobals.getAttackAccuracy(self.skillId) * baseRank damageMod = WeaponGlobals.getAttackTargetHP(self.skillId) * baseRank * 100 reduceDamMod = WeaponGlobals.getAttackSelfHP(self.skillId) * baseRank if reduceDamMod < 1: reduceDamMod *= 100 if effect < 1: effect *= 100 rechargeMod = WeaponGlobals.getAttackRechargeTime(self.skillId) * baseRank * 100 shipTurningMod = WeaponGlobals.getShipTurnRate(self.skillId) * baseRank * 100 shipSpeedMod = WeaponGlobals.getShipMaxSpeed(self.skillId) * baseRank * 100 treasureSenseMod = (WeaponGlobals.TREASURE_SENSE_BONUS / 2) * baseRank rangeMod = WeaponGlobals.getAttackRange(self.skillId) * baseRank manaCost *= baseRank chargeMod = WeaponGlobals.getAttackMaxCharge(self.skillId) * baseRank * 100 if self.skillId == InventoryType.StaffSpiritLore: import pdb as pdb pdb.set_trace() skillInfo = PLocalizer.SkillDescriptions.get(self.skillId) skillTitle = PLocalizer.InventoryTypeNames.get(self.skillId) skillType = 'slant' + skillInfo[0] + '\n\n' description = skillInfo[1] if damage < 0: description += ' ' + PLocalizer.DealsDamage elif damage > 0: if loDamage: description += ' ' + PLocalizer.HealsDamageRange else: description += ' ' + PLocalizer.HealsDamage if mpDamage < 0: description += ' ' + PLocalizer.DealsMpDamage effectId = WeaponGlobals.getSkillEffectFlag(self.skillId) if effectId: description += ' ' + SkillEffectDescriptions.get(effectId)[0] if (self.skillId == InventoryType.SailBroadsideLeft or self.skillId == InventoryType.SailBroadsideRight) and damageMod > 0: description += ' ' + PLocalizer.BroadsideDesc if self.skillId == InventoryType.CannonShoot and rechargeMod: description += ' ' + PLocalizer.CannonShootDesc if self.skillId == InventoryType.DollAttune: description += ' ' + PLocalizer.MultiAttuneDesc if WeaponGlobals.getSkillInterrupt(self.skillId): description += ' ' + PLocalizer.InterruptDesc if WeaponGlobals.getSkillUnattune(self.skillId): description += ' ' + PLocalizer.UnattuneDesc upgradeInfo = '' if self.showUpgrade and self.skillRank < 5: if self.skillRank > 0: upgradeInfo = skillInfo[2] if upgradeInfo == '': if damage < 0: upgradeInfo += PLocalizer.UpgradesDamage elif damage > 0: upgradeInfo += PLocalizer.UpgradesHealing if mpDamage < 0: upgradeInfo += ' ' + PLocalizer.UpgradesMpDamage if effectId: entry = SkillEffectDescriptions.get(effectId) if len(entry) > 1: if not damage: upgradeInfo += PLocalizer.UpgradesDuration else: upgradeInfo += ' ' + PLocalizer.And upgradeInfo += ' ' + entry[1] upgradeInfo += '!' elif len(upgradeInfo) >= 4: upgradeInfo = skillInfo[3] else: upgradeInfo = PLocalizer.ClickToLearn if self.skillId in SkillComboReq and SkillComboReq[self.skillId] and self.skillRank <= 1: description += ' ' + SkillComboReq[self.skillId] skillDesc = 'goldsmallCaps' + skillTitle + '\n' + skillType + description + '\ngreen' + upgradeInfo + '' stats = [] if manaCost: stats.append(abs(manaCost)) if damage and loDamage: stats.append(abs(loDamage)) stats.append(abs(damage)) elif damage: stats.append(abs(damage)) if mpDamage: stats.append(abs(mpLoDamage)) stats.append(abs(mpDamage)) if buff == WeaponGlobals.C_CURSE: stats.append(WeaponGlobals.CURSED_DAM_AMP * 100) if buff == WeaponGlobals.C_ATTUNE and baseRank > 1: stats.append(baseRank) if buff == WeaponGlobals.C_WEAKEN: stats.append(WeaponGlobals.WEAKEN_PENALTY * 100) if effect > 0: stats.append(effect) if dodge: stats.append(abs(dodge)) if accuracy: stats.append(abs(accuracy)) if damageMod: stats.append(abs(damageMod)) if reduceDamMod: stats.append(abs(reduceDamMod)) if rechargeMod: stats.append(abs(rechargeMod)) if shipTurningMod: stats.append(abs(shipTurningMod)) if shipSpeedMod: stats.append(abs(shipSpeedMod)) if chargeMod: stats.append(abs(chargeMod)) if rangeMod: stats.append(abs(rangeMod)) if self.skillId == InventoryType.SailTreasureSense: stats.append(abs(treasureSenseMod)) stats = tuple(stats) if self.skillRank: self.rankText = DirectFrame(parent = self, relief = None, text = ('goldsmallCaps' + PLocalizer.Rank + ' %d' + '') % self.skillRank, text_align = TextNode.ARight, text_scale = PiratesGuiGlobals.TextScaleSmall, text_fg = PiratesGuiGlobals.TextFG2, text_wordwrap = 15, text_shadow = (0, 0, 0, 1), pos = (0.45000000000000001, 0, 0), textMayChange = 1, sortOrder = 92, state = DGG.DISABLED) self.helpText = DirectFrame(parent = self, relief = None, text = skillDesc % stats, text_align = TextNode.ALeft, text_scale = PiratesGuiGlobals.TextScaleSmall, text_fg = PiratesGuiGlobals.TextFG2, text_wordwrap = 15, text_shadow = (0, 0, 0, 1), textMayChange = 1, sortOrder = 91, state = DGG.DISABLED) height = -(self.helpText.getHeight() + 0.01) self.helpBox = BorderFrame(parent = self, frameSize = (-0.040000000000000001, 0.5, height, 0.050000000000000003), pos = (0, 0, -0.12), sortOrder = 90, state = DGG.DISABLED) self.helpBox.setBin('gui-popup', 0) self.helpText.reparentTo(self.helpBox) if self.skillRank: self.rankText.reparentTo(self.helpBox)
def createHelpFrame(self, args=None): if self.helpFrame: return None inv = localAvatar.getInventory() if not inv: return None baseRank = max(self.skillRank, 1) lvlDamageMod = WeaponGlobals.getLevelDamageModifier( localAvatar.getLevel()) buff = WeaponGlobals.getSkillEffectFlag(self.skillId) dur = WeaponGlobals.getAttackDuration(self.skillId) effect = dur + dur * (baseRank - 1) / 4.0 bonus = localAvatar.getSkillRankBonus(self.skillId) upgradeAmt = WeaponGlobals.getAttackUpgrade(self.skillId) rank = localAvatar.getSkillRank(self.skillId) skillBoost = 0 if self.skillId in ItemGlobals.getLinkedSkills( localAvatar.currentWeaponId): linkedSkillId = WeaponGlobals.getLinkedSkillId(self.skillId) skillBoost = ItemGlobals.getWeaponBoosts( localAvatar.currentWeaponId, linkedSkillId) skillBoost += ItemGlobals.getWeaponBoosts( localAvatar.getCurrentCharm(), linkedSkillId) else: skillBoost = ItemGlobals.getWeaponBoosts( localAvatar.currentWeaponId, self.skillId) skillBoost += ItemGlobals.getWeaponBoosts( localAvatar.getCurrentCharm(), self.skillId) manaCost = 0 if WeaponGlobals.getSkillTrack( self.skillId) != WeaponGlobals.PASSIVE_SKILL_INDEX: manaCost = WeaponGlobals.getMojoCost(self.skillId) if manaCost < 0: amt = localAvatar.getSkillRankBonus( InventoryType.StaffConservation) manaCost = min(manaCost - manaCost * amt, 1.0) damage = 0 loDamage = 0 mpDamage = 0 mpLoDamage = 0 if WeaponGlobals.getSkillTrack( self.skillId) == WeaponGlobals.TONIC_SKILL_INDEX: damage = WeaponGlobals.getAttackSelfHP(self.skillId) elif WeaponGlobals.getSkillTrack( self.skillId) != WeaponGlobals.PASSIVE_SKILL_INDEX: mod = (1.0 + bonus) * lvlDamageMod damage = int(WeaponGlobals.getAttackTargetHP(self.skillId) * mod) loDamage = damage / 2 mpDamage = int( WeaponGlobals.getAttackTargetMojo(self.skillId) * mod) mpLoDamage = mpDamage / 2 try: skillInfo = PLocalizer.SkillDescriptions.get(self.skillId) skillTitle = PLocalizer.makeHeadingString( PLocalizer.InventoryTypeNames.get(self.skillId), 2) skillType = PLocalizer.makeHeadingString(skillInfo[0], 1) except: self.notify.error('Error getting skill info for skillId %s' % self.skillId) description = skillInfo[1] if damage < 0: description += ' ' + PLocalizer.DealsDamage elif damage > 0: if loDamage: loDamage = 0 description += ' ' + PLocalizer.HealsDamageRange else: description += ' ' + PLocalizer.HealsDamage if mpDamage < 0: description += ' ' + PLocalizer.DealsMpDamage effectId = WeaponGlobals.getSkillEffectFlag(self.skillId) if effectId: description += ' ' + SkillEffectDescriptions.get(effectId)[0] if bonus: if self.skillId == InventoryType.SailBroadsideLeft or self.skillId == InventoryType.SailBroadsideRight: description += ' ' + PLocalizer.BroadsideDesc if self.skillId == InventoryType.CannonShoot: description += ' ' + PLocalizer.CannonShootDesc if self.skillId == InventoryType.DollAttune: description += ' ' + PLocalizer.MultiAttuneDesc if WeaponGlobals.getSkillInterrupt(self.skillId): description += ' ' + PLocalizer.InterruptDesc if WeaponGlobals.getSkillUnattune(self.skillId): description += ' ' + PLocalizer.UnattuneDesc upgradeInfo = '' if self.showUpgrade and rank < 5: if rank > 0: upgradeInfo = skillInfo[2] if upgradeInfo == '': if damage < 0: upgradeInfo += PLocalizer.UpgradesDamage elif damage > 0: upgradeInfo += PLocalizer.UpgradesHealing if mpDamage < 0: upgradeInfo += ' ' + PLocalizer.UpgradesMpDamage if effectId: entry = SkillEffectDescriptions.get(effectId) if len(entry) > 1: if not damage: upgradeInfo += PLocalizer.UpgradesDuration else: upgradeInfo += ' ' + PLocalizer.And upgradeInfo += ' ' + entry[1] upgradeInfo += '!' elif len(upgradeInfo) >= 4: upgradeInfo = skillInfo[3] else: upgradeInfo = PLocalizer.ClickToLearn elif not self.showIcon: unlockLevel = RepChart.getSkillUnlockLevel(self.skillId) if unlockLevel > 0: upgradeInfo = PLocalizer.UnlocksAtLevel % unlockLevel if self.skillId in SkillComboReq and SkillComboReq[ self.skillId] and inv.getStackQuantity(self.skillId - 1) < 2: color = 'red' if rank == 0: color = 'red' upgradeInfo = '' description += '\n' + color + SkillComboReq[self.skillId] + '.' skillDesc = skillTitle + '\n' + skillType + '\n\n' + description + '\ngreen' + upgradeInfo stats = [] if manaCost: stats.append(abs(manaCost)) if damage and loDamage: stats.append(abs(loDamage)) stats.append(abs(damage)) elif damage: stats.append(abs(damage)) if mpDamage: stats.append(abs(mpLoDamage)) stats.append(abs(mpDamage)) if buff == WeaponGlobals.C_CURSE: stats.append(WeaponGlobals.CURSED_DAM_AMP * 100) if buff == WeaponGlobals.C_WEAKEN: stats.append(WeaponGlobals.WEAKEN_PENALTY * 100) if effect > 0: stats.append(effect) if skillInfo[4]: if bonus == 0 and upgradeAmt > 0: if not self.skillId == InventoryType.SailBroadsideLeft and self.skillId == InventoryType.SailBroadsideRight: pass if not (self.skillId == InventoryType.CannonShoot): bonus = upgradeAmt if upgradeAmt < 1.0 and upgradeAmt > 0: bonus *= 100 if self.skillId == InventoryType.SailTreasureSense: bonus /= 2.0 elif self.skillId == InventoryType.CutlassParry: bonus += WeaponGlobals.getSubtypeParryBonus( localAvatar.currentWeaponId) if bonus: stats.append(abs(bonus)) if self.skillId == InventoryType.DollAttune: stats.append(rank) if self.skillRank: rankText = DirectFrame(parent=self, relief=None, text=PLocalizer.makeHeadingString( PLocalizer.Rank + ' %s' % (self.skillRank + skillBoost), 2), text_align=TextNode.ARight, text_scale=PiratesGuiGlobals.TextScaleSmall, text_fg=PiratesGuiGlobals.TextFG2, text_wordwrap=15, text_shadow=(0, 0, 0, 1), pos=(0.45000000000000001, 0, 0), textMayChange=1, sortOrder=92, state=DGG.DISABLED) stats = [stat + 0.01 for stat in stats] try: pass except TypeError: self.notify.error('Error formatting skillDesc(%s): %s' % (self.skillId, stats)) helpText = DirectFrame(parent=self, relief=None, text=skillDesc % stats, text_align=TextNode.ALeft, text_scale=PiratesGuiGlobals.TextScaleSmall, text_fg=PiratesGuiGlobals.TextFG2, text_wordwrap=17, textMayChange=1, state=DGG.DISABLED, sortOrder=91) height = -(helpText.getHeight() + 0.01) if self.lock: height = height - 0.040000000000000001 width = 0.55000000000000004 self.helpFrame = BorderFrame(parent=self, state=DGG.DISABLED, frameSize=(-0.040000000000000001, width, height, 0.050000000000000003), pos=(0, 0, -0.12), sortOrder=90) self.helpFrame.setBin('gui-popup', 0) helpText.reparentTo(self.helpFrame) if self.skillRank: rankText.reparentTo(self.helpFrame) if self.lock: self.lockedFrame = DirectFrame( parent=self.helpFrame, relief=None, pos=(0.087999999999999995, 0, height + 0.029999999999999999), image=SkillButton.SubLock, image_scale=0.13, image_pos=(-0.055, 0, 0.012999999999999999), text=PLocalizer.VR_AuthAccess, text_scale=PiratesGuiGlobals.TextScaleSmall, text_align=TextNode.ALeft, text_fg=PiratesGuiGlobals.TextFG13) self.notify.debug('locked!') pos = self.helpFrame.getPos(aspect2d) x = min(pos[0], base.a2dRight - width) z = max(pos[2], base.a2dBottom - height) self.helpFrame.setPos(aspect2d, x, 0, z)
def createHelpbox(self, args=None): if self.helpBox: return baseRank = max(self.skillRank, 1) lvlDamageMod = WeaponGlobals.getLevelDamageModifier( localAvatar.getLevel()) buff = WeaponGlobals.getSkillEffectFlag(self.skillId) dur = WeaponGlobals.getAttackDuration(self.skillId) effect = dur + dur * (baseRank - 1) / 4 dodge = WeaponGlobals.getAttackDodge(self.skillId) * baseRank accuracy = 0 damageMod = 0 reduceDamMod = 0 rechargeMod = 0 shipTurningMod = 0 shipSpeedMod = 0 rangeMod = 0 treasureSenseMod = 0 manaCost = WeaponGlobals.getMojoCost(self.skillId) damage = 0 loDamage = 0 mpDamage = 0 chargeMod = 0 if self.skillId == InventoryType.SailBroadsideLeft or self.skillId == InventoryType.SailBroadsideRight: damageMod = WeaponGlobals.getAttackTargetHP( self.skillId) * (baseRank - 1) * 100 else: if self.skillId == InventoryType.CannonShoot: rechargeMod = WeaponGlobals.CANNON_SHOOT_RATE_REDUCTION * ( baseRank - 1) * 100 else: if WeaponGlobals.getSkillTrack( self.skillId) == WeaponGlobals.TONIC_SKILL_INDEX: damage = WeaponGlobals.getAttackSelfHP(self.skillId) else: if WeaponGlobals.getSkillTrack( self.skillId) != WeaponGlobals.PASSIVE_SKILL_INDEX: damage = int( WeaponGlobals.getAttackTargetHP(self.skillId) * (1.0 + WeaponGlobals.LEVELUP_DAMAGE_MULTIPLIER * (baseRank - 1))) * lvlDamageMod loDamage = damage / 2 mpDamage = int( WeaponGlobals.getAttackTargetMojo(self.skillId) * (1.0 + WeaponGlobals.LEVELUP_DAMAGE_MULTIPLIER * (baseRank - 1))) * lvlDamageMod mpLoDamage = mpDamage / 2 else: accuracy = WeaponGlobals.getAttackAccuracy( self.skillId) * baseRank damageMod = WeaponGlobals.getAttackTargetHP( self.skillId) * baseRank * 100 reduceDamMod = WeaponGlobals.getAttackSelfHP( self.skillId) * baseRank if reduceDamMod < 1: reduceDamMod *= 100 if effect < 1: effect *= 100 rechargeMod = WeaponGlobals.getAttackRechargeTime( self.skillId) * baseRank * 100 shipTurningMod = WeaponGlobals.getShipTurnRate( self.skillId) * baseRank * 100 shipSpeedMod = WeaponGlobals.getShipMaxSpeed( self.skillId) * baseRank * 100 treasureSenseMod = WeaponGlobals.TREASURE_SENSE_BONUS / 2 * baseRank rangeMod = WeaponGlobals.getAttackRange( self.skillId) * baseRank manaCost *= baseRank chargeMod = WeaponGlobals.getAttackMaxCharge( self.skillId) * baseRank * 100 if self.skillId == InventoryType.StaffSpiritLore: import pdb pdb.set_trace() skillInfo = PLocalizer.SkillDescriptions.get(self.skillId) skillTitle = PLocalizer.InventoryTypeNames.get( self.skillId) skillType = '\x01slant\x01' + skillInfo[0] + '\x02\n\n' description = skillInfo[1] if damage < 0: description += ' ' + PLocalizer.DealsDamage elif damage > 0: if loDamage: description += ' ' + PLocalizer.HealsDamageRange else: description += ' ' + PLocalizer.HealsDamage if mpDamage < 0: description += ' ' + PLocalizer.DealsMpDamage effectId = WeaponGlobals.getSkillEffectFlag(self.skillId) if effectId: description += ' ' + SkillEffectDescriptions.get( effectId)[0] if self.skillId == InventoryType.SailBroadsideLeft or self.skillId == InventoryType.SailBroadsideRight: if damageMod > 0: description += ' ' + PLocalizer.BroadsideDesc if self.skillId == InventoryType.CannonShoot and rechargeMod: description += ' ' + PLocalizer.CannonShootDesc if self.skillId == InventoryType.DollAttune: description += ' ' + PLocalizer.MultiAttuneDesc if WeaponGlobals.getSkillInterrupt(self.skillId): description += ' ' + PLocalizer.InterruptDesc if WeaponGlobals.getSkillUnattune(self.skillId): description += ' ' + PLocalizer.UnattuneDesc upgradeInfo = '' if self.showUpgrade and self.skillRank < 5: if self.skillRank > 0: upgradeInfo = skillInfo[2] if upgradeInfo == '': if damage < 0: upgradeInfo += PLocalizer.UpgradesDamage elif damage > 0: upgradeInfo += PLocalizer.UpgradesHealing if mpDamage < 0: upgradeInfo += ' ' + PLocalizer.UpgradesMpDamage if effectId: entry = SkillEffectDescriptions.get( effectId) if len(entry) > 1: val = damage or upgradeInfo val += PLocalizer.UpgradesDuration else: upgradeInfo += ' ' + PLocalizer.And upgradeInfo += ' ' + entry[1] upgradeInfo += '!' elif len(upgradeInfo) >= 4: upgradeInfo = skillInfo[3] else: upgradeInfo = PLocalizer.ClickToLearn if self.skillId in SkillComboReq and SkillComboReq[ self.skillId] and self.skillRank <= 1: description += ' ' + SkillComboReq[self.skillId] skillDesc = '\x01gold\x01\x01smallCaps\x01' + skillTitle + '\x02\x02\n' + skillType + description + '\n\x01green\x01' + upgradeInfo + '\x02' stats = [] if manaCost: stats.append(abs(manaCost)) if damage and loDamage: stats.append(abs(loDamage)) stats.append(abs(damage)) elif damage: stats.append(abs(damage)) if mpDamage: stats.append(abs(mpLoDamage)) stats.append(abs(mpDamage)) if buff == WeaponGlobals.C_CURSE: stats.append(WeaponGlobals.CURSED_DAM_AMP * 100) if buff == WeaponGlobals.C_ATTUNE and baseRank > 1: stats.append(baseRank) if buff == WeaponGlobals.C_WEAKEN: stats.append(WeaponGlobals.WEAKEN_PENALTY * 100) if effect > 0: stats.append(effect) if dodge: stats.append(abs(dodge)) if accuracy: stats.append(abs(accuracy)) if damageMod: stats.append(abs(damageMod)) if reduceDamMod: stats.append(abs(reduceDamMod)) if rechargeMod: stats.append(abs(rechargeMod)) if shipTurningMod: stats.append(abs(shipTurningMod)) if shipSpeedMod: stats.append(abs(shipSpeedMod)) if chargeMod: stats.append(abs(chargeMod)) if rangeMod: stats.append(abs(rangeMod)) if self.skillId == InventoryType.SailTreasureSense: stats.append(abs(treasureSenseMod)) stats = tuple(stats) if self.skillRank: self.rankText = DirectFrame( parent=self, relief=None, text=('\x01gold\x01\x01smallCaps\x01' + PLocalizer.Rank + ' %d' + '\x02\x02') % self.skillRank, text_align=TextNode.ARight, text_scale=PiratesGuiGlobals.TextScaleSmall, text_fg=PiratesGuiGlobals.TextFG2, text_wordwrap=15, text_shadow=(0, 0, 0, 1), pos=(0.45, 0, 0), textMayChange=1, sortOrder=92, state=DGG.DISABLED) self.helpText = DirectFrame( parent=self, relief=None, text=skillDesc % stats, text_align=TextNode.ALeft, text_scale=PiratesGuiGlobals.TextScaleSmall, text_fg=PiratesGuiGlobals.TextFG2, text_wordwrap=15, text_shadow=(0, 0, 0, 1), textMayChange=1, sortOrder=91, state=DGG.DISABLED) height = -(self.helpText.getHeight() + 0.01) self.helpBox = BorderFrame(parent=self, frameSize=(-0.04, 0.5, height, 0.05), pos=(0, 0, -0.12), sortOrder=90, state=DGG.DISABLED) self.helpBox.setBin('gui-popup', 0) self.helpText.reparentTo(self.helpBox) if self.skillRank: self.rankText.reparentTo(self.helpBox) return
def __init__(self, skillId, callback, quantity = 0, skillRank = 0, showQuantity = False, showHelp = False, showRing = False, hotkey = None, name = '', showIcon = True, showLock = False, rechargeSkillId = False, isWeaponSkill = False, assocAmmo = []): DirectFrame.__init__(self, parent = NodePath(), relief = None) self.initialiseoptions(SkillButton) gui = loader.loadModel('models/gui/toplevel_gui') if not SkillButton.SkillIcons: print 'not SkillButton.SkillIcons:' SkillButton.SkillIcons = loader.loadModel('models/textureCards/skillIcons') SkillButton.Image = (SkillButton.SkillIcons.find('**/base'), SkillButton.SkillIcons.find('**/base_down'), SkillButton.SkillIcons.find('**/base_over')) SkillButton.SkillRechargedSound = loadSfx(SoundGlobals.SFX_SKILL_RECHARGED) SkillButton.SubLock = gui.find('**/pir_t_gui_gen_key_subscriber') SkillButton.SpecialIcons = [] for entry in SPECIAL_SKILL_ICONS: if not entry: SkillButton.SpecialIcons.append(None) continue specialImage = (SkillButton.SkillIcons.find('**/%s' % entry),) SkillButton.SpecialIcons.append(specialImage) model = loader.loadModel('models/effects/particleMaps') toggleIcon = model.find('**/particleGlow') toggleIcon.node().setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd)) self.toggleFrame = DirectFrame(relief = None, state = DGG.DISABLED, parent = self, image = toggleIcon, image_scale = 0.34999999999999998, image_pos = (0.0, 0.0, -0.01)) self.toggleFrame.hide() self.glowRing = None self.glowRing2 = None self.assocAmmo = assocAmmo self.skillId = skillId self.quantity = quantity self.showQuantity = showQuantity self.skillRank = skillRank self.skillRing = None self.callback = callback self.showUpgrade = False self.showHelp = showHelp self.showRing = showRing self.showIcon = showIcon self.showLock = showLock self.isWeaponSkill = isWeaponSkill self.lock = None self.name = name self.helpFrame = None self.quantityLabel = None self.skillButton = None self.hotkeyLabel = None self.hotkey = hotkey self.greyOut = 0 self.tonicId = 0 self.skillRingIval = None self.impulseIval = None self.quickImpulseIval = None self.isBreakAttackSkill = WeaponGlobals.getSkillTrack(self.skillId) == WeaponGlobals.BREAK_ATTACK_SKILL_INDEX self.isDefenseSkill = WeaponGlobals.getSkillTrack(self.skillId) == WeaponGlobals.DEFENSE_SKILL_INDEX self.rechargeFilled = 0 self.defenseAuraEffect = None if self.isWeaponSkill: self.weaponBackground = DirectLabel(parent = self, state = DGG.DISABLED, image = SkillButton.SkillIcons.find('**/box_base'), image_scale = (0.22, 0, 0.22), image_pos = (0.0, 0.0, 0.0)) self.weaponBackground.flattenLight() self.weaponBackground.setColor(0.20000000000000001, 0.20000000000000001, 0.20000000000000001, 0.20000000000000001) self.weaponBackground.setTransparency(1) if showRing: if self.isBreakAttackSkill: color = Vec4(1, 0, 0, 1) elif self.isDefenseSkill: color = Vec4(0, 1, 1, 1) else: color = Vec4(1, 0.80000000000000004, 0.5, 1) self.skillRing = SkillRing(color, Vec4(0, 0, 0, 1.0)) gs = self.skillRing.meterFaceHalf2.node().getGeomState(0) self.skillRing.meterFaceHalf2.node().setGeomState(0, gs.removeAttrib(ColorAttrib.getClassType())) self.skillRing.reparentTo(self, 0) self.skillRing.setPos(0, 0, 0) self.updateSkillId(skillId) if showQuantity: self.updateQuantity(quantity) if hotkey: self.createHotkey(hotkey) if showLock: self.createLock() self.skillButton.bind(DGG.ENTER, self.showDetails) self.skillButton.bind(DGG.EXIT, self.hideDetails) if self.skillId >= InventoryType.begin_Consumables and self.skillId <= InventoryType.end_Consumables and not WeaponGlobals.getSkillEffectFlag(skillId): self.totalRechargeTime = base.cr.battleMgr.getModifiedRechargeTime(localAvatar, InventoryType.UseItem) self.tonicId = InventoryType.UseItem else: self.totalRechargeTime = base.cr.battleMgr.getModifiedRechargeTime(localAvatar, self.skillId) if showRing: if not self.isBreakAttackSkill: self.createSkillRingIval() if self.tonicId: timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging(InventoryType.UseItem) else: timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging(self.skillId) if self.isBreakAttackSkill and timeSpentRecharging < self.totalRechargeTime: self.updateRechargeRing() elif not (self.isBreakAttackSkill): if (self.totalRechargeTime or timeSpentRecharging) and not (timeSpentRecharging > self.totalRechargeTime): self.skillRingIval.start(startT = timeSpentRecharging) not (timeSpentRecharging > self.totalRechargeTime) self.skillRing.meterFaceHalf1.setR(0) self.skillRing.meterFaceHalf2.setR(180) self.skillRing.meterFaceHalf1.setColor(self.skillRing.meterActiveColor, 100) self.skillRing.meterFaceHalf2.setColor(self.skillRing.meterActiveColor, 100) self.skillRing.meterFaceHalf1.show() self.skillRing.meterFaceHalf2.show() if not self.isBreakAttackSkill: self.checkAmount() if self.isDefenseSkill: self.startRecharge() if self.isWeaponSkill: self.weaponLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.WeaponAbility, text_font = PiratesGlobals.getPirateBoldOutlineFont(), text_align = TextNode.ACenter, text_scale = PiratesGuiGlobals.TextScaleLarge, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, textMayChange = 0, pos = (0.0, 0, -0.12), sortOrder = 70, state = DGG.DISABLED) self.weaponLabel.flattenLight()