def cellUsed(self, cell): if self.manager.heldFromCell: self.heldItemOldCell = self.manager.heldFromCell if self.manager.testCanUse( self.heldItemOldCell.inventoryItem.itemTuple): itemId = self.heldItemOldCell.inventoryItem.itemTuple.getType() skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId) if WeaponGlobals.getSkillEffectFlag(skillId): drunk = localAvatar.guiMgr.combatTray.trySkill( InventoryType.UsePotion, skillId, 0) else: drunk = localAvatar.guiMgr.combatTray.trySkill( InventoryType.UseItem, skillId, 0) if self.waitTime == None and drunk: if WeaponGlobals.getSkillEffectFlag(skillId): self.waitTime = base.cr.battleMgr.getModifiedRechargeTime( localAvatar, InventoryType.UsePotion, skillId) else: self.waitTime = base.cr.battleMgr.getModifiedRechargeTime( localAvatar, InventoryType.UseItem, skillId) if self.waitTime: self.drinkCell['text'] = PLocalizer.WaitPotion % int( self.waitTime) taskMgr.doMethodLater(1.0, self.handlePotionRecharge, 'WaitDrinkPotion') else: localAvatar.guiMgr.createWarning(PLocalizer.HowToDrinkPotion, PiratesGuiGlobals.TextFG6) return
def __init__(self, cr, ammoSkillId, event, buffs=[]): self.trailEffect = None self.buffs = buffs self.glowA = None self.glowB = None self.glowATrack = None self.glowBTrack = None self.rotateIval = None ProjectileAmmo.__init__(self, cr, ammoSkillId, event, True) self.effectFlag = WeaponGlobals.getSkillEffectFlag(ammoSkillId) self.effectIval = None
def __init__(self, cr, ammoSkillId, event, buffs = []): self.trailEffect = None self.buffs = buffs self.glowA = None self.glowB = None self.glowATrack = None self.glowBTrack = None self.rotateIval = None ProjectileAmmo.__init__(self, cr, ammoSkillId, event, True) self.effectFlag = WeaponGlobals.getSkillEffectFlag(ammoSkillId) self.effectIval = None
def cellRightClick(self, cell, mouseAction=MOUSE_CLICK, task=None): if mouseAction == MOUSE_PRESS: if cell.inventoryItem: if self.manager.localDrinkingPotion: localAvatar.guiMgr.createWarning(PLocalizer.NoDoubleDrinkingItemsWarning, PiratesGuiGlobals.TextFG6) return if self.manager.testCanUse(cell.inventoryItem.itemTuple): itemId = cell.inventoryItem.itemTuple.getType() skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId) cell.inventoryItem.hasDrunk = WeaponGlobals.getSkillEffectFlag(skillId) and localAvatar.guiMgr.combatTray.trySkill(InventoryType.UsePotion, skillId, 0) else: cell.inventoryItem.hasDrunk = localAvatar.guiMgr.combatTray.trySkill(InventoryType.UseItem, skillId, 0)
def cellRightClick(self, cell, mouseAction = MOUSE_CLICK, task = None): if mouseAction == MOUSE_PRESS and cell.inventoryItem: if self.manager.localDrinkingPotion: localAvatar.guiMgr.createWarning(PLocalizer.NoDoubleDrinkingItemsWarning, PiratesGuiGlobals.TextFG6) return None if self.manager.testCanUse(cell.inventoryItem.itemTuple): itemId = cell.inventoryItem.itemTuple.getType() skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId) if WeaponGlobals.getSkillEffectFlag(skillId): cell.inventoryItem.hasDrunk = localAvatar.guiMgr.combatTray.trySkill(InventoryType.UsePotion, skillId, 0) else: cell.inventoryItem.hasDrunk = localAvatar.guiMgr.combatTray.trySkill(InventoryType.UseItem, skillId, 0)
def cellUsed(self, cell): if self.manager.heldFromCell: self.heldItemOldCell = self.manager.heldFromCell if self.manager.testCanUse(self.heldItemOldCell.inventoryItem.itemTuple): itemId = self.heldItemOldCell.inventoryItem.itemTuple.getType() skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId) if WeaponGlobals.getSkillEffectFlag(skillId): drunk = localAvatar.guiMgr.combatTray.trySkill(InventoryType.UsePotion, skillId, 0) else: drunk = localAvatar.guiMgr.combatTray.trySkill(InventoryType.UseItem, skillId, 0) if self.waitTime == None and drunk: if WeaponGlobals.getSkillEffectFlag(skillId): self.waitTime = base.cr.battleMgr.getModifiedRechargeTime(localAvatar, InventoryType.UsePotion, skillId) else: self.waitTime = base.cr.battleMgr.getModifiedRechargeTime(localAvatar, InventoryType.UseItem, skillId) if self.waitTime: self.drinkCell['text'] = PLocalizer.WaitPotion % int(self.waitTime) taskMgr.doMethodLater(1.0, self.handlePotionRecharge, 'WaitDrinkPotion') else: localAvatar.guiMgr.createWarning(PLocalizer.HowToDrinkPotion, PiratesGuiGlobals.TextFG6)
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 playOuch(self, skillId, ammoSkillId, targetEffects, attacker, pos, itemEffects=[], multihit=0, targetBonus=0, skillResult=0): (targetHp, targetPower, targetEffect, targetMojo, targetSwiftness) = targetEffects if self.gameFSM.state in ('Injured', ): return None if not targetBonus: if ammoSkillId: effectId = WeaponGlobals.getHitEffect(ammoSkillId) skillEffectId = WeaponGlobals.getSkillEffectFlag(ammoSkillId) else: effectId = WeaponGlobals.getHitEffect(skillId) skillEffectId = WeaponGlobals.getSkillEffectFlag(skillId) if attacker: self.addCombo(attacker.getDoId(), attacker.currentWeaponId, skillId, -targetHp, skillResult) if WeaponGlobals.C_KNOCKDOWN not in self.getSkillEffects( ) or skillEffectId == WeaponGlobals.C_KNOCKDOWN: self.cleanupOuchIval() if not targetBonus and not (self.NoPain) and not ( self.noIntervals) and targetEffects[0] < 0: if self.gameFSM.state not in ( 'Ensnared', 'Knockdown', 'Stunned', 'Rooted', 'NPCInteract', 'ShipBoarding', 'Injured', 'Dying', 'Death' ) or WeaponGlobals.C_KNOCKDOWN in self.getSkillEffects( ) or self.gameFSM.state not in ('ShipBoarding', 'Injured', 'Dying', 'Death'): if WeaponGlobals.C_KNOCKDOWN not in self.getSkillEffects( ) or skillEffectId == WeaponGlobals.C_KNOCKDOWN: ouchSfx = None if self.currentWeapon: if not self.avatarType.isA( AvatarTypes.Creature ) and skillEffectId == WeaponGlobals.C_KNOCKDOWN and not ItemGlobals.getWeaponAttributes( self.currentWeaponId, ItemGlobals.SURE_FOOTED): if self.isLocal(): actorIval = Sequence( self.actorInterval('injured_fall', playRate=1.5, blendOutT=0), self.actorInterval('injured_standup', playRate=1.5, blendInT=0), Func(messenger.send, 'skillFinished')) else: actorIval = Sequence( self.actorInterval('injured_fall', playRate=1.5, blendOutT=0), self.actorInterval('injured_standup', playRate=1.5, blendInT=0)) elif not self.avatarType.isA( AvatarTypes.Creature ) and effectId == WeaponGlobals.VFX_BLIND: actorIval = self.actorInterval( 'sand_in_eyes_holdweapon_noswing', playRate=random.uniform( 0.69999999999999996, 1.5)) else: actorIval = self.actorInterval( self.currentWeapon.painAnim, playRate=random.uniform( 0.69999999999999996, 1.5)) if WeaponGlobals.getIsStaffAttackSkill(skillId): skillInfo = WeaponGlobals.getSkillAnimInfo( skillId) getOuchSfxFunc = skillInfo[ WeaponGlobals.OUCH_SFX_INDEX] if getOuchSfxFunc: ouchSfx = getOuchSfxFunc() else: ouchSfx = self.getSfx('pain') elif not self.avatarType.isA( AvatarTypes.Creature ) and skillEffectId == WeaponGlobals.C_KNOCKDOWN: actorIval = Sequence( self.actorInterval('injured_fall', playRate=1.5, blendOutT=0), self.actorInterval('injured_standup', playRate=1.5, blendInT=0)) elif not self.avatarType.isA( AvatarTypes.Creature ) and effectId == WeaponGlobals.VFX_BLIND: actorIval = self.actorInterval('sand_in_eyes', playRate=random.uniform( 0.69999999999999996, 1.5)) else: actorIval = self.actorInterval('idle_hit', playRate=random.uniform( 0.69999999999999996, 1.5)) if ouchSfx: self.ouchAnim = Sequence( Func(base.playSfx, ouchSfx, node=self, cutoff=75), actorIval) else: self.ouchAnim = actorIval self.ouchAnim.start() skillEffectId == WeaponGlobals.C_KNOCKDOWN if self.combatEffect: self.combatEffect.destroy() self.combatEffect = None self.combatEffect = CombatEffect.CombatEffect(effectId, multihit, attacker, skillResult) self.combatEffect.reparentTo(self) self.combatEffect.setPos(self, pos[0], pos[1], pos[2]) if not WeaponGlobals.getIsDollAttackSkill( skillId) and not WeaponGlobals.getIsStaffAttackSkill(skillId): if not WeaponGlobals.isSelfUseSkill(skillId): if attacker and not attacker.isEmpty(): self.combatEffect.lookAt(attacker) self.combatEffect.setH(self.combatEffect, 180) skillEffects = self.getSkillEffects() if WeaponGlobals.C_MELEE_SHIELD in skillEffects: if WeaponGlobals.getAttackClass( skillId) == WeaponGlobals.AC_COMBAT: self.pulseGhostGuardEffect(attacker, Vec4(0, 0, 0, 1), wantBlending=False) elif WeaponGlobals.C_MISSILE_SHIELD in skillEffects: if WeaponGlobals.getAttackClass( skillId) == WeaponGlobals.AC_MISSILE: self.pulseGhostGuardEffect(attacker, Vec4(1, 1, 1, 1), wantBlending=True) elif WeaponGlobals.C_MAGIC_SHIELD in skillEffects: if WeaponGlobals.getAttackClass(skillId) == WeaponGlobals.AC_MAGIC: self.pulseGhostGuardEffect(attacker, Vec4(0.5, 0.29999999999999999, 1, 1), wantBlending=True) self.combatEffect.play() if WeaponGlobals.getIsDollAttackSkill(skillId): self.voodooSmokeEffect2 = AttuneSmoke.getEffect() if self.voodooSmokeEffect2: self.voodooSmokeEffect2.reparentTo(self) self.voodooSmokeEffect2.setPos(0, 0, 0.20000000000000001) self.voodooSmokeEffect2.play()
def playOuch(self, skillId, ammoSkillId, targetEffects, attacker, pos, itemEffects = [], multihit = 0, targetBonus = 0, skillResult = 0): (targetHp, targetPower, targetEffect, targetMojo, targetSwiftness) = targetEffects if self.gameFSM.state in ('Injured',): return None if not targetBonus: if ammoSkillId: effectId = WeaponGlobals.getHitEffect(ammoSkillId) skillEffectId = WeaponGlobals.getSkillEffectFlag(ammoSkillId) else: effectId = WeaponGlobals.getHitEffect(skillId) skillEffectId = WeaponGlobals.getSkillEffectFlag(skillId) if attacker: self.addCombo(attacker.getDoId(), attacker.currentWeaponId, skillId, -targetHp, skillResult) if WeaponGlobals.C_KNOCKDOWN not in self.getSkillEffects() or skillEffectId == WeaponGlobals.C_KNOCKDOWN: self.cleanupOuchIval() if not targetBonus and not (self.NoPain) and not (self.noIntervals) and targetEffects[0] < 0: if self.gameFSM.state not in ('Ensnared', 'Knockdown', 'Stunned', 'Rooted', 'NPCInteract', 'ShipBoarding', 'Injured', 'Dying', 'Death') or WeaponGlobals.C_KNOCKDOWN in self.getSkillEffects() or self.gameFSM.state not in ('ShipBoarding', 'Injured', 'Dying', 'Death'): if WeaponGlobals.C_KNOCKDOWN not in self.getSkillEffects() or skillEffectId == WeaponGlobals.C_KNOCKDOWN: ouchSfx = None if self.currentWeapon: if not self.avatarType.isA(AvatarTypes.Creature) and skillEffectId == WeaponGlobals.C_KNOCKDOWN and not ItemGlobals.getWeaponAttributes(self.currentWeaponId, ItemGlobals.SURE_FOOTED): if self.isLocal(): actorIval = Sequence(self.actorInterval('injured_fall', playRate = 1.5, blendOutT = 0), self.actorInterval('injured_standup', playRate = 1.5, blendInT = 0), Func(messenger.send, 'skillFinished')) else: actorIval = Sequence(self.actorInterval('injured_fall', playRate = 1.5, blendOutT = 0), self.actorInterval('injured_standup', playRate = 1.5, blendInT = 0)) elif not self.avatarType.isA(AvatarTypes.Creature) and effectId == WeaponGlobals.VFX_BLIND: actorIval = self.actorInterval('sand_in_eyes_holdweapon_noswing', playRate = random.uniform(0.69999999999999996, 1.5)) else: actorIval = self.actorInterval(self.currentWeapon.painAnim, playRate = random.uniform(0.69999999999999996, 1.5)) if WeaponGlobals.getIsStaffAttackSkill(skillId): skillInfo = WeaponGlobals.getSkillAnimInfo(skillId) getOuchSfxFunc = skillInfo[WeaponGlobals.OUCH_SFX_INDEX] if getOuchSfxFunc: ouchSfx = getOuchSfxFunc() else: ouchSfx = self.getSfx('pain') elif not self.avatarType.isA(AvatarTypes.Creature) and skillEffectId == WeaponGlobals.C_KNOCKDOWN: actorIval = Sequence(self.actorInterval('injured_fall', playRate = 1.5, blendOutT = 0), self.actorInterval('injured_standup', playRate = 1.5, blendInT = 0)) elif not self.avatarType.isA(AvatarTypes.Creature) and effectId == WeaponGlobals.VFX_BLIND: actorIval = self.actorInterval('sand_in_eyes', playRate = random.uniform(0.69999999999999996, 1.5)) else: actorIval = self.actorInterval('idle_hit', playRate = random.uniform(0.69999999999999996, 1.5)) if ouchSfx: self.ouchAnim = Sequence(Func(base.playSfx, ouchSfx, node = self, cutoff = 75), actorIval) else: self.ouchAnim = actorIval self.ouchAnim.start() skillEffectId == WeaponGlobals.C_KNOCKDOWN if self.combatEffect: self.combatEffect.destroy() self.combatEffect = None self.combatEffect = CombatEffect.CombatEffect(effectId, multihit, attacker, skillResult) self.combatEffect.reparentTo(self) self.combatEffect.setPos(self, pos[0], pos[1], pos[2]) if not WeaponGlobals.getIsDollAttackSkill(skillId) and not WeaponGlobals.getIsStaffAttackSkill(skillId): if not WeaponGlobals.isSelfUseSkill(skillId): if attacker and not attacker.isEmpty(): self.combatEffect.lookAt(attacker) self.combatEffect.setH(self.combatEffect, 180) skillEffects = self.getSkillEffects() if WeaponGlobals.C_MELEE_SHIELD in skillEffects: if WeaponGlobals.getAttackClass(skillId) == WeaponGlobals.AC_COMBAT: self.pulseGhostGuardEffect(attacker, Vec4(0, 0, 0, 1), wantBlending = False) elif WeaponGlobals.C_MISSILE_SHIELD in skillEffects: if WeaponGlobals.getAttackClass(skillId) == WeaponGlobals.AC_MISSILE: self.pulseGhostGuardEffect(attacker, Vec4(1, 1, 1, 1), wantBlending = True) elif WeaponGlobals.C_MAGIC_SHIELD in skillEffects: if WeaponGlobals.getAttackClass(skillId) == WeaponGlobals.AC_MAGIC: self.pulseGhostGuardEffect(attacker, Vec4(0.5, 0.29999999999999999, 1, 1), wantBlending = True) self.combatEffect.play() if WeaponGlobals.getIsDollAttackSkill(skillId): self.voodooSmokeEffect2 = AttuneSmoke.getEffect() if self.voodooSmokeEffect2: self.voodooSmokeEffect2.reparentTo(self) self.voodooSmokeEffect2.setPos(0, 0, 0.20000000000000001) self.voodooSmokeEffect2.play()
def callback(self, skillId): if WeaponGlobals.getSkillEffectFlag(skillId): localAvatar.guiMgr.combatTray.trySkill(InventoryType.UsePotion, skillId, 0) else: localAvatar.guiMgr.combatTray.trySkill(InventoryType.UseItem, skillId, 0)
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 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 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)
'pot': 0, 'dur': 0, 'unit': 0 }), 'disabled': True, 'potionID': C_CRAB_TRANSFORM, 'ingredients': [ { 'color': 1, 'level': 6 }], 'level': 20, 'free': False, 'discovered': False }, { 'name': PLocalizer.InventoryTypeNames[InventoryType.CannonDamageLvl1], 'desc': safeSubstitute(PLocalizer.PotionDescs[InventoryType.CannonDamageLvl1], { 'pot': int(PotionGlobals.getPotionPotency(WeaponGlobals.getSkillEffectFlag(InventoryType.CannonDamageLvl1)) * 100), 'dur': int(PotionGlobals.getPotionBuffDuration(WeaponGlobals.getSkillEffectFlag(InventoryType.CannonDamageLvl1))), 'unit': 'seconds' }), 'potionID': C_CANNON_DAMAGE_LVL1, 'ingredients': [ { 'color': 0, 'level': 3 }, { 'color': 1, 'level': 3 }, { 'color': 2, 'level': 3 }], 'level': 2, 'free': True,
def callback(self, skillId): if WeaponGlobals.getSkillEffectFlag(skillId): localAvatar.guiMgr.combatTray.trySkill(InventoryType.UsePotion, skillId, 0) else: localAvatar.guiMgr.combatTray.trySkill(InventoryType.UseItem, skillId, 0)
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 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) skillIcons = loader.loadModel('models/textureCards/skillIcons') if itemSubtype == ItemGlobals.POTION_BUFF: self.iconLabel = DirectLabel(parent = self.portraitSceneGraph, relief = None, image = skillIcons.find('**/%s' % ItemGlobals.getIcon(itemId)), pos = (0.0, 2.5, 0.0)) elif model: self.realItem = loader.loadModel('models/inventory/' + model, okMissing = True) if not self.realItem: self.realItem = loader.loadModel('models/handheld/' + 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]) else: self.realItem.setPos(0.0, 2.5, -0.40000000000000002) self.realItem.setHpr(45, 0, 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) if ItemGlobals.getSubtype(itemId) == 30: duration = PotionGlobals.getPotionBuffDuration(WeaponGlobals.getSkillEffectFlag(ItemGlobals.getUseSkill(itemId))) if duration >= 3600: duration = duration / 3600 if duration == 1: units = PLocalizer.Hour else: units = PLocalizer.Hours elif duration >= 60: duration = duration / 60 if duration == 1: units = PLocalizer.Minute else: units = PLocalizer.Minutes else: units = PLocalizer.Seconds potency = PotionGlobals.getPotionPotency(WeaponGlobals.getSkillEffectFlag(ItemGlobals.getUseSkill(itemId))) data = { 'pot': int(potency * 100), 'dur': int(duration), 'unit': units } description = PLocalizer.PotionDescs[ItemGlobals.getUseSkill(itemId)].safe_substitute(data) else: 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) 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 useLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.RightClickPotion, 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 = useLabel.getHeight() runningVertPosition -= uHeight runningSize += uHeight labels.append(useLabel) 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 if detailsHeight: currentHeight = -detailsHeight 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)
WeaponGlobals.C_PISTOL_DAMAGE_LVL1: PotionRecipeData.PotionRecipeList[11]['desc'], WeaponGlobals.C_PISTOL_DAMAGE_LVL2: PotionRecipeData.PotionRecipeList[15]['desc'], WeaponGlobals.C_PISTOL_DAMAGE_LVL3: PotionRecipeData.PotionRecipeList[19]['desc'], WeaponGlobals.C_CUTLASS_DAMAGE_LVL1: PotionRecipeData.PotionRecipeList[12]['desc'], WeaponGlobals.C_CUTLASS_DAMAGE_LVL2: PotionRecipeData.PotionRecipeList[16]['desc'], WeaponGlobals.C_CUTLASS_DAMAGE_LVL3: PotionRecipeData.PotionRecipeList[11]['desc'], WeaponGlobals.C_DOLL_DAMAGE_LVL1: PotionRecipeData.PotionRecipeList[13]['desc'], WeaponGlobals.C_DOLL_DAMAGE_LVL2: PotionRecipeData.PotionRecipeList[17]['desc'], WeaponGlobals.C_DOLL_DAMAGE_LVL3: PotionRecipeData.PotionRecipeList[20]['desc'], WeaponGlobals.C_HASTEN_LVL1: PotionRecipeData.PotionRecipeList[21]['desc'], WeaponGlobals.C_HASTEN_LVL2: PotionRecipeData.PotionRecipeList[22]['desc'], WeaponGlobals.C_HASTEN_LVL3: PotionRecipeData.PotionRecipeList[23]['desc'], WeaponGlobals.C_REP_BONUS_LVL1: PotionRecipeData.PotionRecipeList[24]['desc'], WeaponGlobals.C_REP_BONUS_LVL2: PotionRecipeData.PotionRecipeList[25]['desc'], WeaponGlobals.C_REP_BONUS_LVL3: PLocalizer.PotionDescs[InventoryType.RepBonusLvl1].safe_substitute({ 'pot': int(PotionGlobals.getPotionPotency(WeaponGlobals.getSkillEffectFlag(InventoryType.RepBonusLvl1)) * 100), 'dur': int(PotionGlobals.getPotionBuffDuration(WeaponGlobals.getSkillEffectFlag(InventoryType.RepBonusLvl1))) / 3600, 'unit': 'hour' }), WeaponGlobals.C_REP_BONUS_LVLCOMP: PLocalizer.PotionDescs[InventoryType.RepBonusLvlComp].safe_substitute({ 'pot': int(PotionGlobals.getPotionPotency(WeaponGlobals.getSkillEffectFlag(InventoryType.RepBonusLvlComp)) * 100), 'dur': int(PotionGlobals.getPotionBuffDuration(WeaponGlobals.getSkillEffectFlag(InventoryType.RepBonusLvlComp))) / 3600, 'unit': 'hour' }), WeaponGlobals.C_GOLD_BONUS_LVL1: PotionRecipeData.PotionRecipeList[26]['desc'], WeaponGlobals.C_GOLD_BONUS_LVL2: PotionRecipeData.PotionRecipeList[27]['desc'], WeaponGlobals.C_INVISIBILITY_LVL1: PotionRecipeData.PotionRecipeList[28]['desc'], WeaponGlobals.C_INVISIBILITY_LVL2: PotionRecipeData.PotionRecipeList[29]['desc'], WeaponGlobals.C_REGEN_LVL1: PotionRecipeData.PotionRecipeList[35]['desc'], WeaponGlobals.C_REGEN_LVL2: PotionRecipeData.PotionRecipeList[36]['desc'], WeaponGlobals.C_REGEN_LVL3: PotionRecipeData.PotionRecipeList[37]['desc'], WeaponGlobals.C_REGEN_LVL4: PotionRecipeData.PotionRecipeList[38]['desc'], WeaponGlobals.C_BURP: PotionRecipeData.PotionRecipeList[0]['desc'],
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 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 = '\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) skillIcons = loader.loadModel('models/textureCards/skillIcons') if itemSubtype == ItemGlobals.POTION_BUFF: self.iconLabel = DirectLabel(parent = self.portraitSceneGraph, relief = None, image = skillIcons.find('**/%s' % ItemGlobals.getIcon(itemId)), pos = (0.0, 2.5, 0.0)) elif model: self.realItem = loader.loadModel('models/inventory/' + model, okMissing = True) if not self.realItem: self.realItem = loader.loadModel('models/handheld/' + 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]) else: self.realItem.setPos(0.0, 2.5, -0.40000000000000002) self.realItem.setHpr(45, 0, 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) if ItemGlobals.getSubtype(itemId) == 30: duration = PotionGlobals.getPotionBuffDuration(WeaponGlobals.getSkillEffectFlag(ItemGlobals.getUseSkill(itemId))) if duration >= 3600: duration = duration / 3600 if duration == 1: units = PLocalizer.Hour else: units = PLocalizer.Hours elif duration >= 60: duration = duration / 60 if duration == 1: units = PLocalizer.Minute else: units = PLocalizer.Minutes else: units = PLocalizer.Seconds potency = PotionGlobals.getPotionPotency(WeaponGlobals.getSkillEffectFlag(ItemGlobals.getUseSkill(itemId))) data = { 'pot': int(potency * 100), 'dur': int(duration), 'unit': units } description = PLocalizer.PotionDescs[ItemGlobals.getUseSkill(itemId)].safe_substitute(data) else: 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) 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 useLabel = DirectLabel(parent = self, relief = None, text = PLocalizer.RightClickPotion, 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 = useLabel.getHeight() runningVertPosition -= uHeight runningSize += uHeight labels.append(useLabel) 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 if detailsHeight: currentHeight = -detailsHeight 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)
PotionRecipeData.PotionRecipeList[21]['desc'], WeaponGlobals.C_HASTEN_LVL2: PotionRecipeData.PotionRecipeList[22]['desc'], WeaponGlobals.C_HASTEN_LVL3: PotionRecipeData.PotionRecipeList[23]['desc'], WeaponGlobals.C_REP_BONUS_LVL1: PotionRecipeData.PotionRecipeList[24]['desc'], WeaponGlobals.C_REP_BONUS_LVL2: PotionRecipeData.PotionRecipeList[25]['desc'], WeaponGlobals.C_REP_BONUS_LVL3: safeSubstitute( PLocalizer.PotionDescs[InventoryType.RepBonusLvl1], { 'pot': int( PotionGlobals.getPotionPotency( WeaponGlobals.getSkillEffectFlag( InventoryType.RepBonusLvl1)) * 100), 'dur': int( PotionGlobals.getPotionBuffDuration( WeaponGlobals.getSkillEffectFlag( InventoryType.RepBonusLvl1))) / 3600, 'unit': 'hour' }), WeaponGlobals.C_REP_BONUS_LVLCOMP: safeSubstitute( PLocalizer.PotionDescs[InventoryType.RepBonusLvlComp], { 'pot': int( PotionGlobals.getPotionPotency( WeaponGlobals.getSkillEffectFlag(
'level': 6 }], 'level': 20, 'discovered': False }, { 'name': PLocalizer.InventoryTypeNames[InventoryType.CannonDamageLvl1], 'desc': safeSubstitute( PLocalizer.PotionDescs[InventoryType.CannonDamageLvl1], { 'pot': int( PotionGlobals.getPotionPotency( WeaponGlobals.getSkillEffectFlag( InventoryType.CannonDamageLvl1)) * 100), 'dur': int( PotionGlobals.getPotionBuffDuration( WeaponGlobals.getSkillEffectFlag( InventoryType.CannonDamageLvl1))), 'unit': 'seconds' }), 'potionID': C_CANNON_DAMAGE_LVL1, 'ingredients': [{ 'color': 0, 'level': 3 }, { 'color': 1,
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 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)
WeaponGlobals.C_PISTOL_DAMAGE_LVL1: PotionRecipeData.PotionRecipeList[11]['desc'], WeaponGlobals.C_PISTOL_DAMAGE_LVL2: PotionRecipeData.PotionRecipeList[15]['desc'], WeaponGlobals.C_PISTOL_DAMAGE_LVL3: PotionRecipeData.PotionRecipeList[19]['desc'], WeaponGlobals.C_CUTLASS_DAMAGE_LVL1: PotionRecipeData.PotionRecipeList[12]['desc'], WeaponGlobals.C_CUTLASS_DAMAGE_LVL2: PotionRecipeData.PotionRecipeList[16]['desc'], WeaponGlobals.C_CUTLASS_DAMAGE_LVL3: PotionRecipeData.PotionRecipeList[11]['desc'], WeaponGlobals.C_DOLL_DAMAGE_LVL1: PotionRecipeData.PotionRecipeList[13]['desc'], WeaponGlobals.C_DOLL_DAMAGE_LVL2: PotionRecipeData.PotionRecipeList[17]['desc'], WeaponGlobals.C_DOLL_DAMAGE_LVL3: PotionRecipeData.PotionRecipeList[20]['desc'], WeaponGlobals.C_HASTEN_LVL1: PotionRecipeData.PotionRecipeList[21]['desc'], WeaponGlobals.C_HASTEN_LVL2: PotionRecipeData.PotionRecipeList[22]['desc'], WeaponGlobals.C_HASTEN_LVL3: PotionRecipeData.PotionRecipeList[23]['desc'], WeaponGlobals.C_REP_BONUS_LVL1: PotionRecipeData.PotionRecipeList[24]['desc'], WeaponGlobals.C_REP_BONUS_LVL2: PotionRecipeData.PotionRecipeList[25]['desc'], WeaponGlobals.C_REP_BONUS_LVL3: safeSubstitute(PLocalizer.PotionDescs[InventoryType.RepBonusLvl1], { 'pot': int(PotionGlobals.getPotionPotency(WeaponGlobals.getSkillEffectFlag(InventoryType.RepBonusLvl1)) * 100), 'dur': int(PotionGlobals.getPotionBuffDuration(WeaponGlobals.getSkillEffectFlag(InventoryType.RepBonusLvl1))) / 3600, 'unit': 'hour' }), WeaponGlobals.C_REP_BONUS_LVLCOMP: safeSubstitute(PLocalizer.PotionDescs[InventoryType.RepBonusLvlComp], { 'pot': int(PotionGlobals.getPotionPotency(WeaponGlobals.getSkillEffectFlag(InventoryType.RepBonusLvlComp)) * 100), 'dur': int(PotionGlobals.getPotionBuffDuration(WeaponGlobals.getSkillEffectFlag(InventoryType.RepBonusLvlComp))) / 3600, 'unit': 'hour' }), WeaponGlobals.C_GOLD_BONUS_LVL1: PotionRecipeData.PotionRecipeList[26]['desc'], WeaponGlobals.C_GOLD_BONUS_LVL2: PotionRecipeData.PotionRecipeList[27]['desc'], WeaponGlobals.C_INVISIBILITY_LVL1: PotionRecipeData.PotionRecipeList[28]['desc'], WeaponGlobals.C_INVISIBILITY_LVL2: PotionRecipeData.PotionRecipeList[29]['desc'], WeaponGlobals.C_REGEN_LVL1: PotionRecipeData.PotionRecipeList[35]['desc'], WeaponGlobals.C_REGEN_LVL2: PotionRecipeData.PotionRecipeList[36]['desc'], WeaponGlobals.C_REGEN_LVL3: PotionRecipeData.PotionRecipeList[37]['desc'], WeaponGlobals.C_REGEN_LVL4: PotionRecipeData.PotionRecipeList[38]['desc'], WeaponGlobals.C_BURP: PotionRecipeData.PotionRecipeList[0]['desc'],