コード例 #1
0
 def continuePowerRechargeEffect(self):
     for button in self.tray:
         if isinstance(self.tray[button], SkillButton) and not self.tray[button].isEmpty():
             if (WeaponGlobals.getIsShipSkill(self.tray[button].skillId) or WeaponGlobals.getIsCannonSkill(self.tray[button].skillId)) and self.tray[button].skillId != InventoryType.SailPowerRecharge:
                 self.tray[button].startPowerImpulse()
             
         self.tray[button].skillId != InventoryType.SailPowerRecharge
コード例 #2
0
ファイル: ShipPanel.py プロジェクト: TTGhost/POTCOR-src
    def updateIcons(self):
        shipOV = base.cr.getOwnerView(self.shipId)
        if shipOV:
            shipHullInfo = ShipUpgradeGlobals.HULL_TYPES.get(shipOV.customHull)
            shipRiggingInfo = ShipUpgradeGlobals.RIGGING_TYPES.get(shipOV.customRigging)
            UpgradeIcons = loader.loadModel("models/textureCards/shipUpgradeIcons", okMissing=True)
            skillIcons = loader.loadModel("models/textureCards/skillIcons")
            if shipHullInfo and shipHullInfo["Icon"]:
                if UpgradeIcons:
                    hullImage = UpgradeIcons.find("**/%s" % shipHullInfo["Icon"])
                    self.customHullLabel["geom"] = hullImage

                self.customHullLabel["text"] = shipHullInfo["Name"] + "\n" + PLocalizer.HullLabel
                self.customHullLabel.show()
                self.setShipHp(shipOV.Hp, shipOV.maxHp)
                self.setShipCargo(shipOV.cargo, shipOV.maxCargo)
                if shipHullInfo["BroadsideType"]:
                    broadsideId = shipHullInfo["BroadsideType"]
                    ammoIconName = WeaponGlobals.getSkillIcon(broadsideId)
                    broadsideIcon = skillIcons.find("**/%s" % ammoIconName)
                    self.broadsideLimit["geom"] = broadsideIcon
                    self.broadsideLimit["geom_scale"] = 0.14999999999999999
                else:
                    broadsideId = InventoryType.CannonRoundShot
                    ammoIconName = WeaponGlobals.getSkillIcon(broadsideId)
                    broadsideIcon = skillIcons.find("**/%s" % ammoIconName)
                    self.broadsideLimit["geom"] = broadsideIcon
                    self.broadsideLimit["geom_scale"] = 0.14999999999999999

            if shipRiggingInfo and shipRiggingInfo["Icon"]:
                riggingImage = skillIcons.find("**/%s" % shipRiggingInfo["Icon"])
                self.customRiggingLabel["geom"] = riggingImage
                self.customRiggingLabel["text"] = shipRiggingInfo["Name"] + "\n" + PLocalizer.RiggingLabel
                self.customRiggingLabel.show()
コード例 #3
0
 def updateSkillTrayAmounts(self):
     if not self.traySkillMap:
         return None
     
     if self.weaponMode not in (WeaponGlobals.FIREARM, WeaponGlobals.THROWING, WeaponGlobals.CANNON, WeaponGlobals.GRENADE):
         return None
     
     if not hasattr(base, 'localAvatar'):
         return None
     
     inv = localAvatar.getInventory()
     if not inv:
         return None
     
     self.numberOfItems = len(self.traySkillMap)
     for i in range(self.numberOfItems):
         if self.tray[i + 1].greyOut == -1:
             continue
         
         skillId = self.traySkillMap[i]
         maxQuant = WeaponGlobals.getSkillMaxQuantity(skillId)
         if maxQuant == WeaponGlobals.INF_QUANT and WeaponGlobals.canUseInfiniteAmmo(localAvatar.currentWeaponId, skillId) or WeaponGlobals.canUseInfiniteAmmo(localAvatar.getCurrentCharm(), skillId):
             ammoAmt = WeaponGlobals.INF_QUANT
         else:
             ammoInvId = WeaponGlobals.getSkillAmmoInventoryId(skillId)
             ammoAmt = inv.getStackQuantity(ammoInvId)
             ammoMax = inv.getStackLimit(ammoInvId)
         self.tray[i + 1].updateQuantity(ammoAmt)
 def _DistributedShipBroadside__requestAttack(self, index, side, targetPos, flightTime):
     if side == 0:
         if self.leftBroadside and self.leftBroadsideConfig:
             cannonList = self.leftBroadside
             cannonConfig = self.leftBroadsideConfig
         
         skillId = EnemySkills.LEFT_BROADSIDE
     elif side == 1:
         if self.rightBroadside and self.rightBroadsideConfig:
             cannonList = self.rightBroadside
             cannonConfig = self.rightBroadsideConfig
         
         skillId = EnemySkills.RIGHT_BROADSIDE
     
     ammoSkillId = self.ammoType
     if cannonList and cannonConfig:
         cannonList[index].playFire()
         cballSpawnPoint = cannonList[index].locator
         cballSpawnPoint.setP(render, 0)
         self.playFireEffect(cballSpawnPoint, ammoSkillId)
         if not WeaponGlobals.isProjectileSkill(skillId, ammoSkillId):
             return None
         
         pos = cballSpawnPoint.getPos(render) + Vec3(0, -25, 0)
         if targetPos:
             self.playAttack(skillId, ammoSkillId, pos, targetPos = targetPos, flightTime = flightTime)
         else:
             m = cballSpawnPoint.getMat(self)
             power = WeaponGlobals.getAttackProjectilePower(ammoSkillId) * CannonGlobals.BROADSIDE_POWERMOD
             if side == 1:
                 startVel = m.xformVec(Vec3(0, -power, 90))
             else:
                 startVel = m.xformVec(Vec3(0, -power, 90))
             self.playAttack(skillId, ammoSkillId, pos, startVel)
コード例 #5
0
 def getProjectileInfo(self, skillId, target):
     throwSpeed = WeaponGlobals.getProjectileSpeed(skillId)
     if not throwSpeed:
         return (None, None, None)
     
     placeHolder = self.attachNewNode('projectilePlaceHolder')
     if target:
         if not target.isEmpty():
             placeHolder.setPos(render, target.getPos(render))
             placeHolder.setZ(placeHolder, target.getHeight() * 0.66600000000000004)
         
     else:
         range = WeaponGlobals.getProjectileDefaultRange(skillId)
         if self == localAvatar:
             placeHolder.setPos(camera, 0, range[0], range[1])
         else:
             placeHolder.setPos(self, 0, range[0], 4.0)
     dist = self.getDistance(placeHolder)
     time = dist / throwSpeed
     impactT = time
     animT = WeaponGlobals.getProjectileAnimT(skillId)
     if animT:
         impactT += animT
     
     targetPos = placeHolder.getPos(render)
     placeHolder.removeNode()
     return (targetPos, time, impactT)
コード例 #6
0
 def updateCharmSkills(self):
     self.rebuildSkillTray()
     for button in self.tray:
         if isinstance(self.tray[button], SkillButton) and not self.tray[button].isEmpty():
             if (WeaponGlobals.getIsShipSkill(self.tray[button].skillId) or WeaponGlobals.getIsCannonSkill(self.tray[button].skillId)) and self.tray[button].skillId != InventoryType.SailPowerRecharge:
                 self.tray[button].updateSkillRingIval()
             
         self.tray[button].skillId != InventoryType.SailPowerRecharge
コード例 #7
0
 def removePowerRechargeEffect(self):
     self.isPowerRecharged = False
     for button in self.tray:
         if isinstance(self.tray[button], SkillButton) and not self.tray[button].isEmpty():
             if (WeaponGlobals.getIsShipSkill(self.tray[button].skillId) or WeaponGlobals.getIsCannonSkill(self.tray[button].skillId)) and self.tray[button].skillId != InventoryType.SailPowerRecharge:
                 self.tray[button].stopPowerImpulse()
                 self.tray[button].updateSkillRingIval()
             
         self.tray[button].skillId != InventoryType.SailPowerRecharge
コード例 #8
0
ファイル: SimpleStoreItem.py プロジェクト: TTGhost/POTCOR-src
 def __init__(self, uid):
     SimpleEconomyItem.__init__(self, uid)
     skillId = WeaponGlobals.getSkillIdForAmmoSkillId(uid)
     if skillId:
         asset = WeaponGlobals.getSkillIcon(skillId)
         if asset:
             self.icon = self.Icons.find('**/%s' % asset)
             self.iconScale = 1.1000000000000001
             self.iconHpr = (0, 0, 45)
コード例 #9
0
 def createGui(self):
     itemId = self.data[0]
     self.itemCount += 1
     self.itemQuantity = self.quantity
     self.itemCost = self.price
     self.picture = DirectFrame(parent = self, relief = None, state = DGG.DISABLED, pos = (0.035000000000000003, 0, 0.025000000000000001))
     self.quantityLabel = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = str(self.quantity), text_fg = PiratesGuiGlobals.TextFG2, text_scale = PiratesGuiGlobals.TextScaleSmall * PLocalizer.getHeadingScale(2), text_align = TextNode.ARight, text_wordwrap = 11, pos = (0.1225, 0, 0.014999999999999999))
     if len(self.name) >= 39:
         textScale = PiratesGuiGlobals.TextScaleMicro * PLocalizer.getHeadingScale(2)
     elif len(self.name) >= 35:
         textScale = PiratesGuiGlobals.TextScaleTiny * PLocalizer.getHeadingScale(2)
     else:
         textScale = PiratesGuiGlobals.TextScaleSmall * PLocalizer.getHeadingScale(2)
     self.nameTag = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, text = self.name, text_fg = PiratesGuiGlobals.TextFG2, text_scale = textScale, text_align = TextNode.ALeft, pos = (0.13, 0, 0.014999999999999999))
     self.costText = DirectLabel(parent = self, relief = None, state = DGG.DISABLED, image = InventoryListItem.coinImage, image_scale = 0.12, image_pos = Vec3(-0.0050000000000000001, 0, 0.012500000000000001), text = str(self.price), text_fg = PiratesGuiGlobals.TextFG2, text_scale = PiratesGuiGlobals.TextScaleSmall, text_align = TextNode.ARight, text_wordwrap = 11, text_pos = (-0.029999999999999999, 0, 0), pos = (self.width - 0.035000000000000003, 0, 0.014999999999999999), text_font = PiratesGlobals.getInterfaceFont())
     itemClass = EconomyGlobals.getItemCategory(itemId)
     itemType = EconomyGlobals.getItemType(itemId)
     if itemType == ItemType.FISHING_ROD or itemType == ItemType.FISHING_LURE:
         asset = EconomyGlobals.getItemIcons(itemId)
         if asset:
             self.picture['geom'] = PurchaseListItem.fishingIcons.find('**/%s*' % asset)
             self.picture['geom_scale'] = 0.040000000000000001
             self.picture['geom_pos'] = (0, 0, 0)
         
     elif itemClass == ItemType.WEAPON or itemClass == ItemType.POUCH:
         asset = EconomyGlobals.getItemIcons(itemId)
         if asset:
             self.picture['geom'] = InventoryListItem.weaponIcons.find('**/%s*' % asset)
             self.picture['geom_scale'] = 0.040000000000000001
             self.picture['geom_pos'] = (0, 0, 0)
         
     elif itemClass == ItemType.CONSUMABLE:
         asset = EconomyGlobals.getItemIcons(itemId)
         if asset:
             self.picture['geom'] = InventoryListItem.skillIcons.find('**/%s*' % asset)
             self.picture['geom_scale'] = 0.040000000000000001
             self.picture['geom_pos'] = (0, 0, 0)
         
     
     if not InventoryType.begin_WeaponCannonAmmo <= itemId or itemId <= InventoryType.end_WeaponCannonAmmo:
         if (InventoryType.begin_WeaponPistolAmmo <= itemId or itemId <= InventoryType.end_WeaponGrenadeAmmo or InventoryType.begin_WeaponDaggerAmmo <= itemId) and itemId <= InventoryType.end_WeaponDaggerAmmo:
             skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId)
             if skillId:
                 asset = WeaponGlobals.getSkillIcon(skillId)
                 if asset:
                     self.picture['geom'] = InventoryListItem.skillIcons.find('**/%s' % asset)
                     self.picture['geom_scale'] = 0.059999999999999998
                     self.picture['geom_pos'] = (0, 0, 0)
                 
             
         elif InventoryType.SmallBottle <= itemId and itemId <= InventoryType.LargeBottle:
             self.picture['geom'] = self.topGui.find('**/main_gui_ship_bottle')
             self.picture['geom_scale'] = 0.10000000000000001
             self.picture['geom_pos'] = (0, 0, 0)
         
     self.flattenStrong()
コード例 #10
0
 def getGeomParams(itemId):
     geomParams = { }
     itemType = EconomyGlobals.getItemType(itemId)
     if itemType <= ItemType.WAND or itemType == ItemType.POTION:
         if itemType == ItemType.POTION:
             geomParams['geom'] = InventoryItemGui.skillIcons.find('**/%s' % ItemGlobals.getIcon(itemId))
         else:
             itemType = ItemGlobals.getType(itemId)
             if ItemGlobals.getIcon(itemId):
                 geomParams['geom'] = InventoryItemGui.weaponIcons.find('**/%s' % ItemGlobals.getIcon(itemId))
             
         geomParams['geom_scale'] = 0.11
         geomParams['geom_pos'] = (0.080000000000000002, 0, 0.068000000000000005)
     else:
         itemClass = EconomyGlobals.getItemCategory(itemId)
         itemType = EconomyGlobals.getItemType(itemId)
         if itemType == ItemType.FISHING_ROD or itemType == ItemType.FISHING_LURE:
             asset = EconomyGlobals.getItemIcons(itemId)
             if asset:
                 geomParams['geom'] = InventoryItemGui.fishingIcons.find('**/%s*' % asset)
                 geomParams['geom_scale'] = 0.11
                 geomParams['geom_pos'] = (0.080000000000000002, 0, 0.068000000000000005)
             
         elif itemClass == ItemType.WEAPON and itemClass == ItemType.POUCH or itemClass == ItemType.AMMO:
             asset = EconomyGlobals.getItemIcons(itemId)
             if asset:
                 geomParams['geom'] = InventoryItemGui.weaponIcons.find('**/%s*' % asset)
                 geomParams['geom_scale'] = 0.11
                 geomParams['geom_pos'] = (0.080000000000000002, 0, 0.068000000000000005)
             
         elif itemClass == ItemType.CONSUMABLE:
             asset = EconomyGlobals.getItemIcons(itemId)
             if asset:
                 geomParams['geom'] = InventoryItemGui.skillIcons.find('**/%s*' % asset)
                 geomParams['geom_scale'] = 0.11
                 geomParams['geom_pos'] = (0.080000000000000002, 0, 0.068000000000000005)
             
         
     if not InventoryType.begin_WeaponCannonAmmo <= itemId or itemId <= InventoryType.end_WeaponCannonAmmo:
         if (InventoryType.begin_WeaponPistolAmmo <= itemId or itemId <= InventoryType.end_WeaponGrenadeAmmo or InventoryType.begin_WeaponDaggerAmmo <= itemId) and itemId <= InventoryType.end_WeaponDaggerAmmo:
             skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId)
             if skillId:
                 asset = WeaponGlobals.getSkillIcon(skillId)
                 if asset:
                     geomParams['geom'] = InventoryListItem.skillIcons.find('**/%s' % asset)
                     geomParams['geom_scale'] = 0.14999999999999999
                     geomParams['geom_pos'] = (0.069000000000000006, 0, 0.069000000000000006)
                 
             
         elif InventoryType.SmallBottle <= itemId and itemId <= InventoryType.LargeBottle:
             geomParams['geom'] = InventoryListItem.topGui.find('**/main_gui_ship_bottle')
             geomParams['geom_scale'] = 0.10000000000000001
             geomParams['geom_pos'] = (0.069000000000000006, 0, 0.069000000000000006)
         
     return geomParams
コード例 #11
0
    def updateSkillId(self, skillId):
        self.skillId = skillId
        if self.skillButton:
            if self.quantityLabel:
                self.quantityLabel.detachNode()

            self.skillButton.destroy()

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

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

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

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

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

        if self.showRing:
            image = None
        else:
            image = SkillButton.Image
        self.skillButton = DirectButton(parent = self, relief = None, pos = (0, 0, 0), text = ('', '', self.name), text_align = TextNode.ACenter, text_shadow = Vec4(0, 0, 0, 1), text_scale = 0.040000000000000001, text_fg = Vec4(1, 1, 1, 1), text_pos = (0.0, 0.089999999999999997), image = image, image_scale = 0.14999999999999999, image_color = image_color, geom = geom, geom_scale = geom_scale, geom_color = geomColor, command = self.callback, sortOrder = 50, extraArgs = [
            skillId])
        self.skillButton.bind(DGG.ENTER, self.showDetails)
        self.skillButton.bind(DGG.EXIT, self.hideDetails)
        if self.quantityLabel and not self.quantityLabel.isEmpty():
            self.quantityLabel.reparentTo(self.skillButton)
コード例 #12
0
 def takeAim(self, av, skillId = None, ammoSkillId = None):
     if not self.aimTrav:
         return (None, None)
     
     self.aimTrav.traverse(render)
     numEntries = self.aimQueue.getNumEntries()
     if numEntries == 0:
         return (None, None)
     
     self.aimQueue.sortEntries()
     avTeam = av.getTeam()
     (currentWeaponId, isWeaponDrawn) = av.getCurrentWeapon()
     friendlyWeapon = WeaponGlobals.isFriendlyFireWeapon(currentWeaponId)
     if skillId:
         friendlySkill = WeaponGlobals.isFriendlyFire(skillId, ammoSkillId)
     
     for i in range(numEntries):
         entry = self.aimQueue.getEntry(i)
         targetColl = entry.getIntoNodePath()
         if targetColl.node().getIntoCollideMask().hasBitsInCommon(PiratesGlobals.BattleAimOccludeBitmask):
             break
         
         target = self.getObjectFromNodepath(targetColl)
         if target:
             if targetColl.hasNetPythonTag('MonstrousObject'):
                 dist = entry.getSurfacePoint(localAvatar)[1]
             else:
                 dist = target.getY(av)
             targetTeam = target.getTeam()
             if target.gameFSM.state == 'Death':
                 continue
             
             if dist < 0:
                 continue
             
             if not TeamUtils.damageAllowed(target, localAvatar):
                 if not friendlyWeapon:
                     continue
                 
                 if skillId and not friendlySkill:
                     continue
                 
             
             if not self.cr.battleMgr.obeysPirateCode(av, target):
                 if ItemGlobals.getSubtype(av.currentWeaponId) != ItemGlobals.BAYONET:
                     localAvatar.guiMgr.showPirateCode()
                     continue
                 
             
             return (target, dist)
             continue
         continue
     
     return (None, None)
コード例 #13
0
ファイル: BattleManager.py プロジェクト: TTGhost/POTCOR-src
 def doAttack(self, attacker, skillId, ammoSkillId, targetId, areaIdList, pos, combo = 0, charge = 0):
     attacker.battleRandom.advanceAttackSeed()
     if targetId:
         if WeaponGlobals.getIsShipSkill(skillId):
             target = base.cr.doId2do.get(targetId)
         elif WeaponGlobals.getIsDollAttackSkill(skillId):
             target = base.cr.doId2do.get(targetId)
         else:
             target = base.cr.doId2do.get(targetId)
             if hasattr(target, 'getSkillEffects'):
                 if WeaponGlobals.C_SPAWN in set(target.getSkillEffects()):
                     return WeaponGlobals.RESULT_MISS
                 
             
             if target and not TeamUtils.damageAllowed(localAvatar, target) and not WeaponGlobals.isFriendlyFire(skillId, ammoSkillId):
                 return WeaponGlobals.RESULT_NOT_AVAILABLE
             
     else:
         target = None
     weaponHit = self.willWeaponHit(attacker, target, skillId, ammoSkillId, charge)
     if combo == -1:
         if localAvatar.wantComboTiming:
             return WeaponGlobals.RESULT_MISS
         
     
     if not WeaponGlobals.getNeedTarget(skillId, ammoSkillId):
         return WeaponGlobals.RESULT_HIT
     
     if not target and not areaIdList:
         messenger.send('tooFar')
         return WeaponGlobals.RESULT_MISS
     
     if target and not self.obeysPirateCode(attacker, target):
         if ItemGlobals.getSubtype(localAvatar.currentWeaponId) == ItemGlobals.BAYONET:
             pass
         if not (WeaponGlobals.getAttackClass(skillId) == WeaponGlobals.AC_COMBAT):
             return WeaponGlobals.RESULT_AGAINST_PIRATE_CODE
         
     if target and not self.targetInRange(attacker, target, skillId, ammoSkillId, pos):
         return WeaponGlobals.RESULT_OUT_OF_RANGE
     
     if target and isinstance(target, DistributedBattleNPC.DistributedBattleNPC):
         if target.getGameState()[0] == 'BreakCombat':
             return WeaponGlobals.RESULT_MISS
         
     
     if target:
         skillEffects = target.getSkillEffects()
         if WeaponGlobals.C_SPAWN in skillEffects:
             return WeaponGlobals.RESULT_MISS
         
     
     messenger.send('properHit')
     return weaponHit
 def isSkillValid(self, skillId):
     ammoId = WeaponGlobals.getSkillAmmoInventoryId(skillId)
     ammoName = PLocalizer.InventoryTypeNames.get(ammoId)
     ammoDescription = PLocalizer.WeaponDescriptions.get(ammoId)
     ammoIconName = WeaponGlobals.getSkillIcon(skillId)
     ammoIcon = self.SkillIcons.find("**/%s" % ammoIconName)
     skillRepId = WeaponGlobals.getSkillReputationCategoryId(skillId)
     stackLimit = localAvatar.getInventory().getStackLimit(ammoId)
     if ammoName and ammoDescription and ammoIcon and stackLimit:
         return 1
     else:
         return 0
コード例 #15
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 isSkillValid(self, skillId):
     return WeaponGlobals.getSkillAmmoInventoryId(skillId) in InventoryGlobals.AmmoInGUI
     SkillIcons = loader.loadModel('models/textureCards/skillIcons')
     ammoId = WeaponGlobals.getSkillAmmoInventoryId(skillId)
     ammoName = PLocalizer.InventoryTypeNames.get(ammoId)
     ammoDescription = PLocalizer.WeaponDescriptions.get(ammoId)
     ammoIconName = WeaponGlobals.getSkillIcon(skillId)
     ammoIcon = SkillIcons.find('**/%s' % ammoIconName)
     skillRepId = WeaponGlobals.getSkillReputationCategoryId(skillId)
     if ammoName and ammoDescription and ammoIcon and skillRepId:
         return 1
     else:
         return 0
コード例 #17
0
 def loadWeaponButtons(self):
     for hotkey in self.hotkeys:
         hotkey.destroy()
     
     self.hotkeys = []
     for icon in self.icons:
         icon.destroy()
     
     self.icons = []
     for repMeter in self.repMeters:
         repMeter.destroy()
     
     self.repMeters = []
     self['frameSize'] = (0, self.ICON_WIDTH * len(self.items) + 0.040000000000000001, 0, self.HEIGHT)
     self.setX(-((self.ICON_WIDTH * len(self.items) + 0.040000000000000001) / 2.0))
     topGui = loader.loadModel('models/gui/toplevel_gui')
     kbButton = topGui.find('**/keyboard_button')
     for i in range(len(self.items)):
         if self.items[i]:
             category = WeaponGlobals.getRepId(self.items[i][0])
             icon = DirectFrame(parent = self, state = DGG.DISABLED, relief = None, frameSize = (0, 0.080000000000000002, 0, 0.080000000000000002), pos = (self.ICON_WIDTH * i + 0.080000000000000002, 0, 0.082000000000000003))
             icon.setTransparency(1)
             hotkeyText = 'F%s' % self.items[i][1]
             hotkey = DirectFrame(parent = icon, state = DGG.DISABLED, relief = None, text = hotkeyText, text_align = TextNode.ACenter, text_scale = 0.044999999999999998, text_pos = (0, 0), text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, image = kbButton, image_scale = 0.059999999999999998, image_pos = (0, 0, 0.01), image_color = (0.5, 0.5, 0.34999999999999998, 1), pos = (0, 0, 0.080000000000000002))
             self.hotkeys.append(hotkey)
             category = WeaponGlobals.getRepId(self.items[i][0])
             if Freebooter.getPaidStatus(base.localAvatar.getDoId()) or Freebooter.allowedFreebooterWeapon(category):
                 asset = ItemGlobals.getIcon(self.items[i][0])
                 if asset:
                     texCard = self.card.find('**/%s' % asset)
                     icon['geom'] = texCard
                     icon['geom_scale'] = 0.080000000000000002
                 
                 icon.resetFrameSize()
                 self.icons.append(icon)
             else:
                 texCard = topGui.find('**/pir_t_gui_gen_key_subscriber*')
                 icon['geom'] = texCard
                 icon['geom_scale'] = 0.20000000000000001
                 icon.resetFrameSize()
                 self.icons.append(icon)
             repMeter = DirectWaitBar(parent = icon, relief = DGG.SUNKEN, state = DGG.DISABLED, borderWidth = (0.002, 0.002), range = 0, value = 0, frameColor = (0.23999999999999999, 0.23999999999999999, 0.20999999999999999, 1), barColor = (0.80000000000000004, 0.80000000000000004, 0.69999999999999996, 1), pos = (-0.050000000000000003, 0, -0.052499999999999998), hpr = (0, 0, 0), frameSize = (0.0050000000000000001, 0.095000000000000001, 0, 0.012500000000000001))
             self.repMeters.append(repMeter)
             inv = base.localAvatar.getInventory()
             if inv:
                 repValue = inv.getReputation(category)
                 (level, leftoverValue) = ReputationGlobals.getLevelFromTotalReputation(category, repValue)
                 max = ReputationGlobals.getReputationNeededToLevel(category, level)
                 repMeter['range'] = max
                 repMeter['value'] = leftoverValue
コード例 #18
0
ファイル: SkillPage.py プロジェクト: TTGhost/POTCOR-src
 def getAmmo(self, skillId):
     ammoId = WeaponGlobals.getSkillAmmoInventoryId(skillId)
     if ammoId == None:
         return None
     else:
         amount = localAvatar.getInventory().getStackQuantity(ammoId)
         return amount
コード例 #19
0
 def __init__(self, manager, skillId, itemTuple, imageScaleFactor = 1.0, showMax = 1, update = False):
     self.skillId = skillId
     InventoryUIStackItem.InventoryUIStackItem.__init__(self, manager, itemTuple, imageScaleFactor = imageScaleFactor, showMax = showMax, update = update)
     self.initialiseoptions(InventoryUIAmmoItem)
     SkillIcons = loader.loadModel('models/textureCards/skillIcons')
     self['image'] = SkillIcons.find('**/%s' % WeaponGlobals.getSkillIcon(skillId))
     self.helpFrame = None
     self.cm = CardMaker('itemCard')
     self.cm.setFrame(-0.29999999999999999, 0.29999999999999999, -0.089999999999999997, 0.089999999999999997)
     self.buffer = None
     self.lens = PerspectiveLens()
     self.lens.setNear(0.10000000000000001)
     self.lens.setAspectRatio(0.59999999999999998 / 0.17999999999999999)
     self.realItem = None
     self.iconLabel = None
     self.itemCard = None
     self.portraitSceneGraph = NodePath('PortraitSceneGraph')
     detailGui = loader.loadModel('models/gui/gui_card_detail')
     self.bg = detailGui.find('**/color')
     self.bg.setScale(4)
     self.bg.setPos(0, 17, -6.2999999999999998)
     self.glow = detailGui.find('**/glow')
     self.glow.setScale(3)
     self.glow.setPos(0, 17, -6.2999999999999998)
     self.glow.setColor(1, 1, 1, 0.80000000000000004)
     self.setBin('gui-fixed', 1)
     self.accept('open_main_window', self.createBuffer)
     self.accept('aspectRatioChanged', self.createBuffer)
     self.accept('close_main_window', self.destroyBuffer)
     self['image_scale'] = 0.10000000000000001 * imageScaleFactor
コード例 #20
0
 def selectPrev(self):
     if len(self.items) < 1:
         return None
     
     self.show()
     if len(self.items) > 1:
         keepTrying = True
     else:
         keepTrying = False
     while keepTrying:
         keepTrying = False
         self.choice = self.choice - 1
         if self.choice < 0 or self.choice > len(self.items) - 1:
             self.choice = len(self.items) - 1
         
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             if self.items[self.choice]:
                 category = WeaponGlobals.getRepId(self.items[self.choice][0])
                 if not Freebooter.allowedFreebooterWeapon(category):
                     keepTrying = True
                 
             else:
                 keepTrying = True
         self.items[self.choice]
     self.cursor.setPos(self.ICON_WIDTH * self.choice + 0.080000000000000002, 0, 0.071999999999999995)
     taskMgr.remove('BarSelectHideTask' + str(self.getParent()))
     self.hideTask = taskMgr.doMethodLater(self.SelectionDelay, self.confirmSelection, 'BarSelectHideTask' + str(self.getParent()), extraArgs = [])
コード例 #21
0
 def verifyCombo(self, avId, weaponId, skillId, timestamp):
     if skillId in self.EXCLUDED_SKILLS:
         return 0
     
     combo = self.timers.get(avId)
     if not combo:
         return 0
     
     comboLength = len(combo)
     lastEntry = combo[comboLength - 1]
     lastSkillId = lastEntry[self.SKILLID_INDEX]
     lastTimestamp = lastEntry[self.TIMESTAMP_INDEX]
     subtypeId = ItemGlobals.getSubtype(weaponId)
     if not subtypeId:
         return 0
     
     comboChain = self.COMBO_ORDER.get(subtypeId)
     if not comboChain:
         return 0
     
     repId = WeaponGlobals.getSkillReputationCategoryId(skillId)
     if not repId:
         return 0
     
     if skillId in comboChain:
         index = comboChain.index(skillId)
         requisiteAttack = comboChain[index - 1]
         currentAttack = comboChain[index]
         if lastSkillId != requisiteAttack and lastSkillId != currentAttack and lastSkillId not in self.SPECIAL_SKILLS.get(repId, []):
             return 0
         
     
     return 1
コード例 #22
0
def getSkillIconName(skillId, frame):
    if skillId == InventoryType.FishingRep:
        return 'pir_t_ico_swd_broadsword_b'
    
    if skillId == InventoryType.CutlassRep:
        return 'pir_t_ico_swd_broadsword_b'
    elif skillId == InventoryType.SailingRep:
        return 'sail_full_sail'
    elif skillId == InventoryType.CannonRep:
        return 'pir_t_ico_can_single'
    elif skillId == InventoryType.WandRep:
        return 'pir_t_ico_stf_dark_a'
    elif skillId == InventoryType.MeleeRep:
        return 'pir_t_ico_swd_broadsword_b'
    elif skillId == InventoryType.DaggerRep:
        return 'pir_t_ico_knf_small'
    elif skillId == InventoryType.GrenadeRep:
        return 'pir_t_ico_bom_grenade'
    elif skillId == InventoryType.PistolRep:
        return 'pir_t_ico_gun_pistol_a'
    elif skillId == InventoryType.DollRep:
        if frame == 0:
            return 'pir_t_ico_dol_spirit_a'
        else:
            return 'voodoo_attuned'
    else:
        return WeaponGlobals.getSkillIcon(skillId)
 def setupPlunder(self, plunderList):
     for (itemClass, itemId, stackAmount) in plunderList:
         itemTuple = [
             itemClass,
             itemId,
             0,
             stackAmount]
         if itemClass == InventoryType.ItemTypeWeapon:
             item = self.manager.makeWeaponItem(itemTuple)
         elif itemClass == InventoryType.ItemTypeCharm:
             item = self.manager.makeCharmItem(itemTuple)
         elif itemClass == InventoryType.ItemTypeConsumable:
             item = self.manager.makeConsumableItem(itemTuple, showMax = 0)
         elif itemClass == InventoryType.ItemTypeClothing:
             item = self.manager.makeClothingItem(itemTuple)
         elif itemClass == InventoryType.ItemTypeMoney:
             item = self.manager.makeGoldItem(itemTuple)
         elif itemClass == InventoryType.TreasureCollection:
             item = self.manager.makeTreasureItem(itemTuple)
         elif itemClass == InventoryCategory.CARDS:
             cardId = itemId
             itemTuple[1] -= InventoryType.begin_Cards
             item = self.manager.makeCardItem(cardId, itemTuple, imageScaleFactor = 1.8999999999999999)
         elif itemClass == InventoryCategory.WEAPON_PISTOL_AMMO:
             itemTuple[1] = WeaponGlobals.getSkillAmmoInventoryId(itemId)
             item = self.manager.makeAmmoItem(itemId, itemTuple, showMax = 0)
         
         if itemClass in (InventoryType.ItemTypeMoney, InventoryCategory.CARDS, InventoryType.TreasureCollection):
             self.addGridCell(self.stackImage, 1.0)
         elif itemClass == InventoryCategory.WEAPON_PISTOL_AMMO:
             self.addGridCell(self.stackImage2, 1.0)
         else:
             self.addGridCell()
         self.tryPutIntoFirstOpenCell(item)
コード例 #24
0
 def addTab(self, itemGroup, item):
     newTab = self.tabBar.addTab(itemGroup, command = self.setPage, extraArgs = [
         itemGroup])
     repId = WeaponGlobals.getRepId(item)
     if repId:
         iconName = ReputationGlobals.RepIcons.get(repId)
         if repId == InventoryType.FishingRep:
             icon = StoreGUI.FishingIcons.find('**/%s' % iconName)
         else:
             icon = StoreGUI.WeaponIcons.find('**/%s' % iconName)
     elif InventoryType.begin_Consumables <= item:
         pass
     elif repId or ItemGlobals.getClass(item) == InventoryType.ItemTypeConsumable:
         iconName = EconomyGlobals.getItemIcons(item)
         icon = StoreGUI.SkillIcons.find('**/%s' % iconName)
     elif InventoryType.begin_WeaponCannonAmmo <= item:
         pass
     elif ItemGlobals.getClass(item) == InventoryType.ItemTypeConsumable:
         iconName = EconomyGlobals.getItemIcons(InventoryType.CannonL1)
         icon = StoreGUI.WeaponIcons.find('**/%s' % iconName)
     elif InventoryType.begin_WeaponGrenadeAmmo <= item:
         pass
     elif ItemGlobals.getClass(item) == InventoryType.ItemTypeConsumable:
         itemId = InventoryType.GrenadeWeaponL1
         iconName = EconomyGlobals.getItemIcons(itemId)
         icon = StoreGUI.WeaponIcons.find('**/%s' % iconName)
     elif InventoryType.begin_FishingLures <= item:
         pass
     elif ItemGlobals.getClass(item) == InventoryType.ItemTypeConsumable:
         icon = StoreGUI.FishingIcons.find('**/pir_t_gui_gen_fish_lure')
     else:
         icon = None
     newTab.nameTag = DirectLabel(parent = newTab, relief = None, state = DGG.DISABLED, image = icon, image_scale = 0.40000000000000002, image_pos = (0, 0, 0.040000000000000001), pos = (0.059999999999999998, 0, -0.035000000000000003))
     self.pageNames.append(itemGroup)
コード例 #25
0
 def checkComboExpired(self, avId, weaponId, skillId, skillResult):
     barTime = 3.0
     curTime = globalClock.getFrameTime()
     for attackerId in self.timers:
         comboLength = len(self.timers[attackerId])
         lastEntry = self.timers[attackerId][comboLength - 1]
         lastSkillId = lastEntry[self.SKILLID_INDEX]
         timestamp = lastEntry[self.TIMESTAMP_INDEX]
         if (barTime + timestamp - curTime) + self.TOLERANCE > 0:
             if attackerId != avId:
                 return 0
             
             subtypeId = ItemGlobals.getSubtype(weaponId)
             if not subtypeId:
                 return 0
             
             repId = WeaponGlobals.getSkillReputationCategoryId(skillId)
             if not repId:
                 return 0
             
             if repId != WeaponGlobals.getRepId(weaponId):
                 return 0
             
             comboChain = self.COMBO_ORDER.get(subtypeId)
             if comboChain:
                 if not self.SPECIAL_SKILLS.get(repId, []):
                     self.notify.warning('No special skills for weapon %s with skill %s, subtype %s, rep %s' % (weaponId, skillId, subtypeId, repId))
                 
                 if skillId in self.SPECIAL_SKILLS.get(repId, []):
                     if lastSkillId not in self.SPECIAL_SKILLS.get(repId, []):
                         return 0
                     
                 elif skillId in comboChain:
                     index = comboChain.index(skillId)
                     if index > 0:
                         requisiteAttack = comboChain[index - 1]
                         if lastSkillId == requisiteAttack:
                             return 0
                         
                     elif not comboLength:
                         return 0
                     
                 
             
     
     return 1
 def setupCells(self):
     self.gridBackground = self.attachNewNode('grid-background')
     WeaponIcons = loader.loadModel('models/gui/gui_icons_weapon')
     gui = loader.loadModel('models/gui/toplevel_gui')
     chestButtonClosed = gui.find('**/treasure_chest_closed_over')
     self.figureOutStackTypes()
     if len(self.listOfItemLists) == 0:
         return None
     
     self.computeCellSize()
     for Z in range(self.gridZ):
         for X in range(len(self.listOfItemLists[Z])):
             skillId = self.listOfItemLists[Z][X]
             if self.subBagTypeToBagId.has_key(skillId) and skillId not in self.subBagTypesCreated:
                 if self.seperatorOn:
                     self.seperatorCount += 1
                 else:
                     self.seperatorOn = 1
                     self.gapOn = 1
                 bagId = self.subBagTypeToBagId[skillId]
                 cellPos = self.findGridPos(X, Z)
                 bagCell = self.makeCell(self.cellImage)
                 bagCell.setPos(cellPos)
                 bagItem = self.makeAmmoBagItem(skillId, bagId)
                 self.putIntoCell(bagItem, bagCell)
                 self.subBagTypesCreated.append(skillId)
                 bagCell['image'] = None
                 continue
             if skillId in self.subBagTypesCreated:
                 continue
             cellPos = self.findGridPos(X, Z, self.gapOn)
             ammoCell = self.getCell()
             ammoCell.setPos(cellPos)
             ammoId = WeaponGlobals.getSkillAmmoInventoryId(skillId)
             newItem = self.getItem(skillId, ammoId)
             if newItem:
                 if self.textOffset != None:
                     newItem.textOffset = self.textOffset
                 
                 self.putIntoCell(newItem, ammoCell)
                 ammoCell['image_color'] = (1.0, 1.0, 1.0, 1.0)
             else:
                 ammoCell['image_color'] = (0.5, 0.5, 0.5, 1.0)
             self.makeCellBacking(cellPos)
         
     
     for i in self.cellList:
         n = NodePath(i.node().getStateDef(0)).getChild(0)
         if i.getNumChildren() > 1:
             n2 = NodePath(i.getChild(1).node().getStateDef(0)).getChild(0)
             newGeomC = n2.copyTo(self.gridBackground)
             newGeomC.setPos(i.getPos())
             n2.hide()
         
         NodePath(i.node().getStateDef(2)).hide()
         n.hide()
     
     self.gridBackground.flattenStrong()
コード例 #27
0
 def __str__(self):
     s = 'BattleSkillDiary\n'
     s += ' Skill: Timestamp\n'
     for (skillId, details) in self._BattleSkillDiary__timers.items():
         skillName = WeaponGlobals.getSkillName(skillId)
         state = ('Idle', 'Charging')[details[0]]
         dt = details[1]
         timeStamp = details[2]
         remaining = self.getTimeRemaining(skillId)
         s += ' %s (%s): %s, dt=%f, t=%f, remaining=%f (s)\n' % (skillName, skillId, state, dt, timeStamp, remaining)
     
     for (skillId, details) in self._BattleSkillDiary__hits.items():
         skillName = WeaponGlobals.getSkillName(skillId)
         hits = details[0]
         remaining = self.getTimeRemaining(skillId)
         s += ' %s (%s): %s, hits=%f, remaining=%f (s)\n' % (skillName, skillId, hits, remaining)
     
     return s
 def playAttack(self, skillId, ammoSkillId, pos = 0, startVel = 0, targetPos = None, flightTime = 0):
     if not WeaponGlobals.isProjectileSkill(skillId, ammoSkillId):
         if self.localAvatarUsingWeapon:
             localAvatar.composeRequestTargetedSkill(skillId, ammoSkillId)
         
         return None
     
     self.ammoSequence = self.ammoSequence + 1 & 255
     buffs = []
     if self.av:
         buffs = self.av.getSkillEffects()
     
     ammo = self.getProjectile(ammoSkillId, self.projectileHitEvent, buffs)
     ammo.setPos(pos)
     if skillId == EnemySkills.LEFT_BROADSIDE:
         ammo.setH(render, self.ship.getH(render) + 90)
     elif skillId == EnemySkills.RIGHT_BROADSIDE:
         ammo.setH(render, self.ship.getH(render) - 90)
     
     collNode = ammo.getCollNode()
     collNode.reparentTo(render)
     ammo.setTag('ammoSequence', str(self.ammoSequence))
     ammo.setTag('skillId', str(int(skillId)))
     ammo.setTag('ammoSkillId', str(int(ammoSkillId)))
     if self.av:
         ammo.setTag('attackerId', str(self.av.doId))
     
     startPos = pos
     endPlaneZ = -10
     if self.ship:
         ammo.setTag('shipId', str(self.ship.doId))
         self.shotNum += 1
         if self.shotNum > 100000:
             self.shotNum = 0
         
         ammo.setTag('shotNum', str(self.shotNum))
         self.baseVel = self.ship.worldVelocity
     
     if startPos[2] < endPlaneZ:
         self.notify.warning('bad startPos Z: %s' % startPos[2])
         return None
     
     if targetPos is None:
         startVel += self.baseVel
         pi = ProjectileInterval(ammo, startPos = startPos, startVel = startVel, endZ = endPlaneZ, gravityMult = 2.0, collNode = collNode)
     elif self.ship.getNPCship():
         pi = ProjectileInterval(ammo, endZ = endPlaneZ, startPos = startPos, wayPoint = targetPos, timeToWayPoint = flightTime, gravityMult = 0.5, collNode = collNode)
     else:
         pi = ProjectileInterval(ammo, endZ = endPlaneZ, startPos = startPos, wayPoint = targetPos, timeToWayPoint = flightTime, gravityMult = 1.2, collNode = collNode)
     if base.cr.cannonballCollisionDebug == 1 or base.cr.cannonballCollisionDebug == 2:
         addFunc = Func(base.cTrav.addCollider, collNode, ammo.collHandler)
         delFunc = Func(base.cTrav.removeCollider, collNode)
     else:
         addFunc = Wait(0)
         delFunc = Wait(0)
     s = Parallel(Sequence(Wait(0.10000000000000001), addFunc), Sequence(pi, Func(ammo.destroy), delFunc))
     ammo.setIval(s, start = True)
 def figureOutStackTypes(self):
     self.listOfItemLists = []
     for pouchType in orderedPouchTypes:
         ammoList = EconomyGlobals.getPouchAmmoList(pouchType)
         continue
         itemList = [ WeaponGlobals.getSkillIdForAmmoSkillId(ammoId) for ammoId in ammoList ]
         itemList.insert(0, pouchType)
         self.listOfItemLists.append(itemList)
     
     self.discoverPouches()
 def playOuch(self, skillId, ammoSkillId, targetEffects, attacker, pos, itemEffects = [], multihit = 0, targetBonus = 0, skillResult = 0):
     (targetHp, targetPower, targetEffect, targetMojo, targetSwiftness) = targetEffects
     if attacker:
         self.addCombo(attacker.getDoId(), attacker.currentWeaponId, skillId, -targetHp)
     
     self.cleanupOuchIval()
     if not targetBonus:
         if ammoSkillId:
             effectId = WeaponGlobals.getHitEffect(ammoSkillId)
         else:
             effectId = WeaponGlobals.getHitEffect(skillId)
     
     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'):
             ouchSfx = None
             currentAnim = self.getCurrentAnim()
             if currentAnim == 'run':
                 painAnim = 'run_hit'
             elif currentAnim == 'walk':
                 painAnim = 'walk_hit'
             else:
                 painAnim = 'idle_hit'
             actorIval = self.actorInterval(painAnim, playRate = random.uniform(0.69999999999999996, 1.5))
             if self.currentWeapon and WeaponGlobals.getIsStaffAttackSkill(skillId):
                 skillInfo = WeaponGlobals.getSkillAnimInfo(skillId)
                 getOuchSfxFunc = skillInfo[WeaponGlobals.OUCH_SFX_INDEX]
                 if getOuchSfxFunc:
                     ouchSfx = getOuchSfxFunc()
                 
             else:
                 ouchSfx = self.getSfx('pain')
             if ouchSfx:
                 self.ouchAnim = Sequence(Func(base.playSfx, ouchSfx, node = self, cutoff = 75), actorIval)
             else:
                 self.ouchAnim = actorIval
             self.ouchAnim.start()
         
     
     if self.combatEffect:
         self.combatEffect.destroy()
         self.combatEffect = None
     
     self.combatEffect = CombatEffect.CombatEffect(effectId, multihit, attacker)
     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 attacker and not attacker.isEmpty():
             self.combatEffect.lookAt(attacker)
         
         self.combatEffect.setH(self.combatEffect, 180)
     
     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()
コード例 #31
0
    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'
                elif 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])
                        elif itemType == ItemGlobals.SWORD:
                            self.realItem.setPos(-1.5, 3.0, -0.3)
                            self.realItem.setHpr(90, 170, -90)
                        elif itemSubtype in (ItemGlobals.MUSKET,
                                             ItemGlobals.BAYONET):
                            self.realItem.setPos(-1.2, 3.0, -0.1)
                            self.realItem.setHpr(0, 135, 10)
                        elif itemSubtype == ItemGlobals.BLUNDERBUSS:
                            self.realItem.setPos(-0.3, 2.0, 0.0)
                            self.realItem.setHpr(0, 90, 0)
                        elif itemType == ItemGlobals.GUN:
                            self.realItem.setPos(-0.5, 2.0, -0.2)
                            self.realItem.setHpr(0, 90, 0)
                        elif itemType == ItemGlobals.DOLL:
                            self.realItem.setPos(0.0, 1.9, -0.1)
                            self.realItem.setHpr(0, 90, 180)
                        elif itemType == ItemGlobals.DAGGER:
                            self.realItem.setPos(-1.0, 2.0, -0.3)
                            self.realItem.setHpr(90, 170, -90)
                        elif itemType == ItemGlobals.GRENADE:
                            self.realItem.setPos(0.0, 3.5, -0.2)
                            self.realItem.setHpr(0, 0, 0)
                        elif 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 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.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
                    elif 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))
                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.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)
                if basePosZ > 0.0:
                    newPosZ = basePosZ + cellSizeZ * 0.45
                newPosZ = basePosZ + totalHeight - cellSizeZ * 0.75
            if detailsPos:
                newPosX, newPosZ = detailsPos
        self.helpFrame.setPos(newPosX, 0, newPosZ)
        return
コード例 #32
0
ファイル: WeaponPage.py プロジェクト: rasheelprogrammer/potco
    def rePanel(self, inventory):
        if not self.showing:
            self.needRefresh = 1
            return None

        skillTokens = {
            InventoryType.CutlassToken: (ItemGlobals.RUSTY_CUTLASS, ),
            InventoryType.PistolToken: (ItemGlobals.FLINTLOCK_PISTOL, ),
            InventoryType.DollToken: (ItemGlobals.VOODOO_DOLL, ),
            InventoryType.DaggerToken: (ItemGlobals.BASIC_DAGGER, ),
            InventoryType.GrenadeToken: (ItemGlobals.GRENADE_POUCH, ),
            InventoryType.WandToken: (ItemGlobals.CURSED_STAFF, )
        }
        zIndex = 1
        for skillTokenKey in TOKEN_LIST:
            quantity = 0
            if localAvatar.getInventory().stacks.get(skillTokenKey):
                quantity = 1

            skillData = skillTokens[skillTokenKey]
            weaponId = skillData[0]
            key = None
            panel = WeaponPanel.WeaponPanel((weaponId, quantity), key)
            panel.reparentTo(self)
            panel.setZ(PiratesGuiGlobals.InventoryPanelHeight -
                       0.17999999999999999 - zIndex * panel.height)
            zIndex += 1
            repCat = WeaponGlobals.getRepId(weaponId)
            self.weaponPanels[repCat] = panel
            self.ignore('inventoryQuantity-%s' % inventory.getDoId())
            self.acceptOnce(
                'inventoryQuantity-%s-%s' %
                (inventory.getDoId(), skillTokenKey), self.refreshList)

        repIcon_gui = loader.loadModel('models/textureCards/skillIcons')
        repIcon = repIcon_gui.find('**/box_base')
        if config.GetBool('want-fishing-game', 0):
            self.fishingIcon = GuiButton(
                pos=(0.16600000000000001, 0, 0.044999999999999998 +
                     (PiratesGuiGlobals.InventoryPanelHeight -
                      0.17999999999999999) - zIndex * panel.height),
                helpText=PLocalizer.FishingRepDescription,
                helpOpaque=True,
                image=(repIcon, repIcon, repIcon, repIcon),
                image_scale=(0.14399999999999999, 0.14399999999999999,
                             0.14399999999999999))
            fishIconCard = loader.loadModel(
                'models/textureCards/fishing_icons')
            inv = localAvatar.getInventory()
            fishingChangeMsg = InventoryGlobals.getCategoryQuantChangeMsg(
                inv.doId, InventoryType.FishingRod)
            if self.fishingChangeMsg:
                self.ignore(fishingChangeMsg)

            self.fishingChangeMsg = fishingChangeMsg
            self.acceptOnce(fishingChangeMsg, self.refreshList)
            rodIcons = [
                'pir_t_gui_fsh_smRodIcon', 'pir_t_gui_fsh_mdRodIcon',
                'pir_t_gui_fsh_lgRodIcon'
            ]
            rodLvl = inv.getStackQuantity(InventoryType.FishingRod)
            rodIcon = rodIcons[rodLvl - 1]
            rodText = PLocalizer.FishingRodNames[rodLvl]
            if rodLvl >= 1:
                self.fishingIcon['geom'] = fishIconCard.find('**/' + rodIcon)

            self.fishingIcon['geom_scale'] = 0.10000000000000001
            self.fishingIcon['geom_pos'] = (0, 0, 0)
            self.fishingIcon.reparentTo(self)
            fishingRepValue = localAvatar.getInventory().getReputation(
                InventoryType.FishingRep)
            self.fishingRepMeter = ReputationMeter(InventoryType.FishingRep,
                                                   width=0.66000000000000003)
            self.fishingRepMeter.setPos(
                0.62, 0, 0.041000000000000002 +
                (PiratesGuiGlobals.InventoryPanelHeight - 0.17999999999999999)
                - zIndex * panel.height)
            self.fishingRepMeter.update(fishingRepValue)
            self.fishingRepMeter.reparentTo(self)
            self.fishingRepMeter.flattenLight()
            self.fishingPoleName = DirectLabel(
                parent=self,
                relief=None,
                state=DGG.DISABLED,
                text=rodText,
                text_scale=PiratesGuiGlobals.TextScaleSmall,
                text_align=TextNode.ALeft,
                text_fg=PiratesGuiGlobals.TextFG2,
                text_shadow=PiratesGuiGlobals.TextShadow,
                pos=(0.28999999999999998, 0, -0.0050000000000000001 +
                     (PiratesGuiGlobals.InventoryPanelHeight -
                      0.17999999999999999) - 7 * panel.height),
                text_font=PiratesGlobals.getInterfaceFont())
            self.fishingPoleName.reparentTo(self)
            zIndex += 1

        iconCard = loader.loadModel('models/textureCards/skillIcons')
        if config.GetBool('want-potion-game', 0):
            self.potionIcon = GuiButton(
                pos=(0.16600000000000001, 0, 0.044999999999999998 +
                     (PiratesGuiGlobals.InventoryPanelHeight -
                      0.17999999999999999) - zIndex * panel.height),
                helpText=PLocalizer.PotionRepDescription,
                helpOpaque=True,
                image=(repIcon, repIcon, repIcon, repIcon),
                image_scale=(0.14399999999999999, 0.14399999999999999,
                             0.14399999999999999))
            self.potionIcon['geom'] = iconCard.find('**/pir_t_gui_pot_base')
            self.potionIcon['geom_scale'] = 0.10000000000000001
            self.potionIcon['geom_pos'] = (0, 0, 0)
            self.potionIcon.reparentTo(self)
            potionRepValue = localAvatar.getInventory().getReputation(
                InventoryType.PotionsRep)
            self.potionRepMeter = ReputationMeter(InventoryType.PotionsRep,
                                                  width=0.66000000000000003)
            self.potionRepMeter.setPos(
                0.62, 0, 0.041000000000000002 +
                (PiratesGuiGlobals.InventoryPanelHeight - 0.17999999999999999)
                - zIndex * panel.height)
            self.potionRepMeter.update(potionRepValue)
            self.potionRepMeter.reparentTo(self)
            self.potionRepMeter.flattenLight()
            zIndex += 1

        items = dict(
            map(lambda x: (x.getType(), x.getCount()),
                inventory.getConsumables().values()))
        possibleItems = ItemGlobals.getAllHealthIds()
        havePorky = items.get(ItemGlobals.ROAST_PORK)
        if not havePorky and ItemGlobals.ROAST_PORK in possibleItems:
            possibleItems.remove(ItemGlobals.ROAST_PORK)

        offset = 0
        if base.config.GetBool('want-potion-game', 0):
            items = inventory.getConsumables()
            listLength = len(InventoryType.PotionMinigamePotions)
            count = 0
            for i in range(listLength):
                tonicId = InventoryType.PotionMinigamePotions[i]
                if items.get(tonicId):
                    button = SkillButton(tonicId,
                                         self.tonicCallback,
                                         items.get(tonicId),
                                         showQuantity=True,
                                         showHelp=True,
                                         showRing=True)
                    button.skillButton['geom_scale'] = 0.080000000000000002
                    x = 0.16 * (count % 6) + -1.2
                    z = 1.0 - int(count / 6) * 0.16
                    button.setPos(x, 0, z)
                    button.reparentTo(self)
                    self.tonicButtons[tonicId] = button
                    count += 1
                    continue
コード例 #33
0
    def __init__(self, shipPage, shipId, **kwargs):
        self.shipPage = shipPage
        self.emptyBottle = True
        self.setShipId(shipId)
        self.timer = None
        self.lBroadsideLimit = 0
        self.rBroadsideLimit = 0
        kwargs.setdefault('relief', None)
        kwargs.setdefault('frameSize', (0, self.Width, 0, self.Height))
        DirectFrame.__init__(self, **None)
        self.initialiseoptions(ShipPanel)
        gui = loader.loadModel('models/gui/toplevel_gui')
        inventoryGui = loader.loadModel('models/gui/gui_icons_inventory')
        chestIcon = inventoryGui.find('**/pir_t_ico_trs_chest_01*')
        cannonIcon = gui.find('**/topgui_icon_ship_cannon_single')
        skillIcons = loader.loadModel('models/textureCards/skillIcons')
        broadsideId = InventoryType.CannonRoundShot
        ammoIconName = WeaponGlobals.getSkillIcon(broadsideId)
        broadsideIcon = skillIcons.find('**/%s' % ammoIconName)
        crewIcon = (gui.find('**/pir_t_gui_gen_friends_pirates'), )
        self.bottleFrame = ShipFrameBottle(parent=self,
                                           shipId=shipId,
                                           relief=None,
                                           state=DGG.DISABLED,
                                           pos=(0.074999999999999997, 0, 0.75),
                                           scale=0.83499999999999996)
        gui = loader.loadModel('models/gui/gui_ship_window')
        bottleImage = gui.find('**/ship_bottle')
        self.shipBottle = DirectLabel(parent=self.bottleFrame,
                                      relief=None,
                                      state=DGG.DISABLED,
                                      geom=bottleImage,
                                      geom_scale=0.29999999999999999,
                                      geom_pos=(0, 0, 0),
                                      pos=(0.5, 0, -0.0))
        self.nameLabel = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            text=PLocalizer.makeHeadingString(PLocalizer.EmptyBottle, 2),
            text_fg=PiratesGuiGlobals.TextFG1,
            text_scale=PiratesGuiGlobals.TextScaleTitleSmall,
            text_align=TextNode.ACenter,
            text_shadow=(0, 0, 0, 1),
            text_wordwrap=30,
            textMayChange=1,
            text_font=PiratesGlobals.getPirateFont(),
            pos=(0.55000000000000004, 0, 1.22))
        self.classLabel = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            text=PLocalizer.makeHeadingString(PLocalizer.EmptyBottleDesc, 1),
            text_scale=PiratesGuiGlobals.TextScaleMed,
            text_align=TextNode.ACenter,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=(0, 0, 0, 1),
            text_wordwrap=30,
            textMayChange=1,
            text_font=PiratesGlobals.getInterfaceFont(),
            pos=(0.55000000000000004, 0, 1.1799999999999999))
        self.timer = PiratesTimer.PiratesTimer(showMinutes=True,
                                               mode=None,
                                               titleText='',
                                               titleFg='',
                                               infoText='',
                                               cancelText='',
                                               cancelCallback=None)
        self.timer.setFontColor(PiratesGuiGlobals.TextFG2)
        self.timer.reparentTo(self)
        self.timer.setPos(0.45000000000000001, 0, 0.93999999999999995)
        self.timer.setScale(0.59999999999999998)
        self.timer.stash()
        self.hpMeter = DirectWaitBar(
            parent=self,
            relief=DGG.RAISED,
            state=DGG.DISABLED,
            range=1,
            value=0,
            frameColor=(0.0, 0.0, 0.0, 0.0),
            barColor=(0.10000000000000001, 0.69999999999999996,
                      0.10000000000000001, 1),
            frameSize=(0, 0.31, 0, 0.018599999999999998),
            text='',
            text_align=TextNode.ARight,
            text_scale=0.029999999999999999,
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
            text_pos=(0.29999999999999999, 0.029999999999999999),
            pos=(0.55000000000000004, 0.0, 0.45000000000000001),
            scale=1.2)
        hpLabel = DirectLabel(parent=self.hpMeter,
                              relief=None,
                              state=DGG.DISABLED,
                              text=PLocalizer.HP,
                              text_scale=0.029999999999999999,
                              text_align=TextNode.ALeft,
                              text_pos=(0.014999999999999999,
                                        0.029999999999999999),
                              text_fg=(1, 1, 1, 1),
                              text_shadow=(0, 0, 0, 1))
        self.speedMeter = DirectWaitBar(
            parent=self,
            relief=DGG.RAISED,
            state=DGG.DISABLED,
            range=1,
            value=0,
            frameColor=(0.0, 0.0, 0.0, 0.0),
            barColor=(0.69999999999999996, 0.69999999999999996,
                      0.10000000000000001, 1),
            frameSize=(0, 0.31, 0, 0.018599999999999998),
            text='',
            text_align=TextNode.ARight,
            text_scale=0.029999999999999999,
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
            text_pos=(0.29999999999999999, 0.029999999999999999),
            pos=(0.55000000000000004, 0.0, 0.34999999999999998),
            scale=1.2)
        speedLabel = DirectLabel(parent=self.speedMeter,
                                 relief=None,
                                 state=DGG.DISABLED,
                                 text=PLocalizer.Sails,
                                 text_scale=0.029999999999999999,
                                 text_align=TextNode.ALeft,
                                 text_pos=(0.014999999999999999,
                                           0.029999999999999999),
                                 text_fg=(1, 1, 1, 1),
                                 text_shadow=(0, 0, 0, 1))
        self.customHullLabel = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            geom=chestIcon,
            geom_scale=0.14999999999999999,
            geom_pos=(0, 0, 0),
            text='',
            text_scale=0.044999999999999998,
            text_align=TextNode.ACenter,
            text_pos=(0, -0.070000000000000007),
            text_fg=PiratesGuiGlobals.TextFG1,
            text_shadow=(0, 0, 0, 1),
            textMayChange=1,
            text_font=PiratesGlobals.getInterfaceOutlineFont(),
            pos=(0.34999999999999998, 0, 0.68000000000000005))
        self.customHullLabel.hide()
        self.customRiggingLabel = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            geom=chestIcon,
            geom_scale=0.14999999999999999,
            geom_pos=(0, 0, 0),
            text='',
            text_scale=0.044999999999999998,
            text_align=TextNode.ACenter,
            text_pos=(0, -0.070000000000000007),
            text_fg=PiratesGuiGlobals.TextFG1,
            text_shadow=(0, 0, 0, 1),
            textMayChange=1,
            text_font=PiratesGlobals.getInterfaceOutlineFont(),
            pos=(0.75, 0, 0.68000000000000005))
        self.customRiggingLabel.hide()
        textPos = (0.0, -0.16)
        self.plunderLimit = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            geom=chestIcon,
            geom_scale=0.10000000000000001,
            geom_pos=(0, 0, -0.050000000000000003),
            text='',
            text_scale=0.044999999999999998,
            text_align=TextNode.ACenter,
            text_pos=textPos,
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
            textMayChange=1,
            text_font=PiratesGlobals.getInterfaceOutlineFont(),
            pos=(0.20000000000000001, 0, 0.20000000000000001))
        plunderLabel = DirectLabel(parent=self.plunderLimit,
                                   relief=None,
                                   state=DGG.DISABLED,
                                   text=PLocalizer.Cargo,
                                   text_scale=0.035999999999999997,
                                   text_align=TextNode.ACenter,
                                   text_pos=(0, 0.040000000000000001),
                                   text_fg=(1, 1, 1, 1),
                                   text_shadow=(0, 0, 0, 1))
        self.cannonLimit = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            geom=cannonIcon,
            geom_scale=0.45000000000000001,
            geom_pos=(0, 0, -0.050000000000000003),
            text='',
            text_scale=0.044999999999999998,
            text_align=TextNode.ACenter,
            text_pos=textPos,
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
            textMayChange=1,
            text_font=PiratesGlobals.getInterfaceOutlineFont(),
            pos=(0.37, 0, 0.20000000000000001))
        cannonLabel = DirectLabel(parent=self.cannonLimit,
                                  relief=None,
                                  state=DGG.DISABLED,
                                  text=PLocalizer.Cannon,
                                  text_scale=0.035999999999999997,
                                  text_align=TextNode.ACenter,
                                  text_pos=(0, 0.040000000000000001),
                                  text_fg=(1, 1, 1, 1),
                                  text_shadow=(0, 0, 0, 1))
        self.cannonLabel = cannonLabel
        self.broadsideLimit = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            geom=broadsideIcon,
            geom_scale=0.14999999999999999,
            geom_pos=(0, 0, -0.050000000000000003),
            text='',
            text_scale=0.044999999999999998,
            text_align=TextNode.ACenter,
            text_pos=textPos,
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
            textMayChange=1,
            text_font=PiratesGlobals.getInterfaceOutlineFont(),
            pos=(0.81000000000000005, 0, 0.20000000000000001))
        broadsideLabel = DirectLabel(parent=self.broadsideLimit,
                                     relief=None,
                                     state=DGG.DISABLED,
                                     text=PLocalizer.Broadsides,
                                     text_scale=0.035999999999999997,
                                     text_align=TextNode.ACenter,
                                     text_fg=(1, 1, 1, 1),
                                     text_shadow=(0, 0, 0, 1),
                                     text_pos=(0.0, 0.040000000000000001))
        self.broadsideLabel = broadsideLabel
        self.crewLimit = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            geom=crewIcon,
            geom_scale=0.40000000000000002,
            geom_pos=(0, 0, 0.10000000000000001),
            text='',
            text_scale=0.044999999999999998,
            text_align=TextNode.ACenter,
            text_fg=(1, 1, 1, 1),
            text_shadow=(0, 0, 0, 1),
            textMayChange=1,
            text_font=PiratesGlobals.getInterfaceOutlineFont(),
            pos=(0.56000000000000005, 0, 0.040000000000000001))
        crewLabel = DirectLabel(parent=self.crewLimit,
                                relief=None,
                                state=DGG.DISABLED,
                                text=PLocalizer.Crew,
                                text_scale=0.035999999999999997,
                                text_align=TextNode.ACenter,
                                text_pos=(0.0, 0.20000000000000001),
                                text_fg=(1, 1, 1, 1),
                                text_shadow=(0, 0, 0, 1))
        self.crewLabel = crewLabel
        shipOV = base.cr.getOwnerView(self.shipId)
        if shipOV:
            self.setShipName(shipOV.name)
            self.setShipClass(shipOV.shipClass)
            self.setShipHp(shipOV.Hp, shipOV.maxHp)
            self.setShipSp(shipOV.Sp, shipOV.maxSp)
            self.setShipCrew(shipOV.crew, shipOV.maxCrew)
            self.setShipCargo([], shipOV.maxCargo)
            if hasattr(shipOV, 'cannonConfig'):
                self.setShipMaxCannons(shipOV.cannonConfig)
                self.setShipMaxBroadside(shipOV.lBroadsideConfig,
                                         shipOV.rBroadsideConfig)

            self.updateIcons()

        if self.emptyBottle:
            self.hpMeter.hide()
            self.speedMeter.hide()
            self.plunderLimit.hide()
            self.cannonLimit.hide()
            self.broadsideLimit.hide()
            self.crewLimit.hide()

        self.accept('setName-%s' % self.shipId, self.setShipName)
        self.accept('setShipClass-%s' % self.shipId, self.setShipClass)
        self.accept('setShipHp-%s' % self.shipId, self.setShipHp)
        self.accept('setShipSp-%s' % self.shipId, self.setShipSp)
        self.accept('setShipCargo-%s' % self.shipId, self.setShipCargo)
        self.accept('setShipCrew-%s' % self.shipId, self.setShipCrew)
        self.accept('setShipTimer-%s' % self.shipId, self.setShipTimer)
        self.accept('setHullCannonConfig-%s' % self.shipId,
                    self.setShipMaxCannons)
        self.accept('setHullLeftBroadsideConfig-%s' % self.shipId,
                    self.setShipMaxLeftBroadside)
        self.accept('setHullRightBroadsideConfig-%s' % self.shipId,
                    self.setShipMaxRightBroadside)
        self.accept('ShipChanged-%s' % self.shipId, self.handleShipChanged)
        if base.config.GetBool('want-deploy-button', 0):
            pass
        1
コード例 #34
0
 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
     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()
     ouchSfx = not targetBonus and not self.NoPain and not self.noIntervals and targetEffects[
         0] < 0 and (
             self.gameFSM.state not in
             ('Ensnared', 'Knockdown', 'Stunned', 'Rooted', 'NPCInteract',
              'ShipBoarding', 'Injured', 'Dying', 'Death')
             or WeaponGlobals.C_KNOCKDOWN in self.getSkillEffects()
             and self.gameFSM.state not in
             ('ShipBoarding', 'Injured', 'Dying', 'Death')) and (
                 WeaponGlobals.C_KNOCKDOWN not in self.getSkillEffects()
                 or skillEffectId == WeaponGlobals.C_KNOCKDOWN) and None
     if self.currentWeapon:
         if not self.avatarType.isA(AvatarTypes.Creature):
             if skillEffectId == WeaponGlobals.C_KNOCKDOWN:
                 if 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))
                 else:
                     if not self.avatarType.isA(AvatarTypes.Creature):
                         if effectId == WeaponGlobals.VFX_BLIND:
                             actorIval = self.actorInterval(
                                 'sand_in_eyes_holdweapon_noswing',
                                 playRate=random.uniform(0.7, 1.5))
                         else:
                             actorIval = self.actorInterval(
                                 self.currentWeapon.painAnim,
                                 playRate=random.uniform(0.7, 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')
                     else:
                         if not self.avatarType.isA(AvatarTypes.Creature):
                             actorIval = skillEffectId == WeaponGlobals.C_KNOCKDOWN and Sequence(
                                 self.actorInterval('injured_fall',
                                                    playRate=1.5,
                                                    blendOutT=0),
                                 self.actorInterval('injured_standup',
                                                    playRate=1.5,
                                                    blendInT=0))
                         else:
                             if not self.avatarType.isA(
                                     AvatarTypes.Creature):
                                 actorIval = effectId == WeaponGlobals.VFX_BLIND and self.actorInterval(
                                     'sand_in_eyes',
                                     playRate=random.uniform(0.7, 1.5))
                             else:
                                 actorIval = self.actorInterval(
                                     'idle_hit',
                                     playRate=random.uniform(0.7, 1.5))
                     if ouchSfx:
                         self.ouchAnim = Sequence(
                             Func(base.playSfx,
                                  ouchSfx,
                                  node=self,
                                  cutoff=75), actorIval)
                     else:
                         self.ouchAnim = actorIval
                     self.ouchAnim.start()
         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):
             if 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()
             WeaponGlobals.C_MELEE_SHIELD in skillEffects and WeaponGlobals.getAttackClass(
                 skillId
             ) == WeaponGlobals.AC_COMBAT and self.pulseGhostGuardEffect(
                 attacker, Vec4(0, 0, 0, 1), wantBlending=False)
     else:
         if WeaponGlobals.C_MISSILE_SHIELD in skillEffects:
             if WeaponGlobals.getAttackClass(
                     skillId) == WeaponGlobals.AC_MISSILE:
                 self.pulseGhostGuardEffect(attacker,
                                            Vec4(1, 1, 1, 1),
                                            wantBlending=True)
         else:
             if WeaponGlobals.C_MAGIC_SHIELD in skillEffects:
                 if WeaponGlobals.getAttackClass(
                         skillId) == WeaponGlobals.AC_MAGIC:
                     self.pulseGhostGuardEffect(attacker,
                                                Vec4(0.5, 0.3, 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.2)
             self.voodooSmokeEffect2.play()
     return
コード例 #35
0
 def updateSkillId(self, skillId):
     self.skillId = skillId
     if self.skillButton:
         if self.quantityLabel:
             self.quantityLabel.detachNode()
         self.skillButton.destroy()
     if self.showQuantity:
         if not self.quantity:
             geomColor = Vec4(0.5, 0.5, 0.5, 1.0)
         else:
             geomColor = Vec4(1.0, 1.0, 1.0, 1.0)
         if self.showIcon:
             asset = WeaponGlobals.getSkillIcon(skillId)
             if hasattr(self, '_skillIconName'):
                 asset = self._skillIconName
             geom = SkillButton.SkillIcons.find('**/%s' % asset)
             if geom.isEmpty():
                 geom = SkillButton.SkillIcons.find('**/base')
             repId = WeaponGlobals.getSkillReputationCategoryId(
                 self.skillId)
             geom_scale = getGeomScale(repId, skillId)
             image_color = (1, 1, 1, 1)
         else:
             geom = (None, )
             geom_scale = 0.12
             image_color = (0.5, 0.5, 0.5, 0.5)
         specialIconId = 0
         if self.isBreakAttackSkill:
             specialIconId = 1
         else:
             if self.isDefenseSkill:
                 specialIconId = 2
             else:
                 if skillId == ItemGlobals.getSpecialAttack(
                         localAvatar.currentWeaponId):
                     specialIconId = 3
         if specialIconId:
             something = SkillButton.SpecialIcons[specialIconId][0]
             if self.skillRing:
                 self.skillRing.setupFace(something)
             self['image'] = None
         else:
             if self.skillRing:
                 self.skillRing.setupFace()
         image = self.showRing and None
     else:
         image = SkillButton.Image
     self.skillButton = DirectButton(parent=self,
                                     relief=None,
                                     pos=(0, 0, 0),
                                     text=('', '', self.name),
                                     text_align=TextNode.ACenter,
                                     text_shadow=Vec4(0, 0, 0, 1),
                                     text_scale=0.04,
                                     text_fg=Vec4(1, 1, 1, 1),
                                     text_pos=(0.0, 0.09),
                                     image=image,
                                     image_scale=0.15,
                                     image_color=image_color,
                                     geom=geom,
                                     geom_scale=geom_scale,
                                     geom_color=geomColor,
                                     command=self.callback,
                                     sortOrder=50,
                                     extraArgs=[skillId])
     self.skillButton.bind(DGG.ENTER, self.showDetails)
     self.skillButton.bind(DGG.EXIT, self.hideDetails)
     if self.quantityLabel and not self.quantityLabel.isEmpty():
         self.quantityLabel.reparentTo(self.skillButton)
     return
コード例 #36
0
ファイル: Cannon.py プロジェクト: rasheelprogrammer/pirates
    def playAttack(self,
                   skillId,
                   ammoSkillId,
                   projectileHitEvent,
                   targetPos=None,
                   wantCollisions=0,
                   flightTime=None,
                   preciseHit=False,
                   buffs=[],
                   timestamp=None,
                   numShots=1,
                   shotNum=-1):
        if base.cr.wantSpecialEffects != 0:
            self.playFireEffect(ammoSkillId, buffs)
        if ammoSkillId == InventoryType.CannonGrapeShot:
            numShots = 7
            disperseAmount = (35, 0.0)
        else:
            disperseAmount = (40, 20.0)
        wantCollisions = 1
        self.ammoSequence = self.ammoSequence + 1 & 255
        if ammoSkillId in (InventoryType.DefenseCannonScatterShot,
                           InventoryType.CannonGrapeShot):
            scatterOffset = random.uniform(0, 360)
        for i in range(numShots):
            ammo = self.getProjectile(ammoSkillId, projectileHitEvent, buffs)
            collNode = None
            if self.localAvatarUsingWeapon or wantCollisions:
                collNode = ammo.getCollNode()
                collNode.reparentTo(render)
            if shotNum > -1:
                self.shotNum = shotNum
            else:
                self.shotNum += 1
            if self.shotNum > 100000:
                self.shotNum = 0
            ammo.setTag('shotNum', str(self.shotNum))
            ammo.setTag('ammoSequence', str(self.ammoSequence))
            ammo.setTag('skillId', str(int(skillId)))
            ammo.setTag('ammoSkillId', str(int(ammoSkillId)))
            if self.av:
                ammo.setTag('attackerId', str(self.av.doId))
            if hasattr(self, 'fortId'):
                ammo.setTag('fortId', str(self.fortId))
            if hasattr(self, 'ship'):
                if self.ship:
                    if hasattr(self.ship, 'doId'):
                        setShipTag = True
                        if setShipTag:
                            ammo.setTag('shipId', str(self.ship.doId))
                    startPos = self.cannonExitPoint.getPos(render)
                    ammo.setPos(startPos)
                    ammo.setH(self.hNode.getH(render))
                    ammo.setP(self.pivot.getP(render))
                    endPlaneZ = -100
                    if startPos[2] < endPlaneZ:
                        self.notify.warning('bad startPos Z: %s' % startPos[2])
                        return
                    m = ammo.getMat(render)
                    curPower = WeaponGlobals.getAttackProjectilePower(
                        skillId, ammoSkillId) * 0.6
                    if targetPos is None:
                        if ammoSkillId in (
                                InventoryType.DefenseCannonScatterShot,
                                InventoryType.CannonGrapeShot):
                            if i > 0:
                                dist = Vec3(
                                    math.fabs(
                                        random.gauss(0, disperseAmount[0])) +
                                    disperseAmount[1], curPower, 0.0)
                                angle = Mat3.rotateMatNormaxis(
                                    random.uniform(0, 360 / numShots) +
                                    i * 360 / (numShots - 1) + scatterOffset,
                                    Vec3.forward())
                                dist = angle.xform(dist)
                                startVel = m.xformVec(dist)
                            else:
                                startVel = m.xformVec(Vec3(0, curPower, 0))
                            if self.ship:
                                fvel = self.ship.smoother.getSmoothForwardVelocity(
                                ) * 0.5
                                faxis = self.ship.smoother.getForwardAxis()
                                self.baseVel = faxis * fvel
                                startVel += self.baseVel
                        else:
                            startVel = m.xformVec(Vec3(0, 20, 2))

                        def attachRope():
                            if (ammoSkillId == InventoryType.CannonGrappleHook
                                    and self).cannonPost:
                                rope = self.getRope()
                                rope.reparentTo(ammo)
                                rope.setup(
                                    3, ((None, Point3(0, 0, 0)),
                                        (self.cannonPost, Point3(2, 5, 10)),
                                        (self.cannonPost, Point3(2, 0, 0))))
                            return

                        if preciseHit and flightTime is None:
                            flightTime = CannonGlobals.AI_FIRE_TIME
                        pi = ProjectileInterval(ammo,
                                                startPos=startPos,
                                                endPos=targetPos,
                                                duration=flightTime,
                                                collNode=collNode)
                    else:
                        if targetPos:
                            if flightTime is None:
                                flightTime = CannonGlobals.getCannonballFlightTime(
                                    startPos, targetPos, curPower)
                            pi = ProjectileInterval(ammo,
                                                    endZ=endPlaneZ,
                                                    startPos=startPos,
                                                    wayPoint=targetPos,
                                                    timeToWayPoint=flightTime,
                                                    gravityMult=2.5,
                                                    collNode=collNode)
                        else:
                            pi = ProjectileInterval(ammo,
                                                    startPos=startPos,
                                                    startVel=startVel,
                                                    endZ=endPlaneZ,
                                                    gravityMult=4.0,
                                                    collNode=collNode)
                    addFunc = (self.localAvatarUsingWeapon
                               or wantCollisions) and (
                                   base.cr.cannonballCollisionDebug == 1
                                   or base.cr.cannonballCollisionDebug
                                   == 3) and Func(base.cTrav.addCollider,
                                                  collNode, ammo.collHandler)
                    delFunc = Func(base.cTrav.removeCollider, collNode)
                else:
                    addFunc = Wait(0)
                    delFunc = Wait(0)
                s = Sequence(addFunc, Func(attachRope), pi, Func(ammo.destroy),
                             delFunc)
            else:
                s = Sequence(Func(attachRope), pi, Func(ammo.destroy))
            ts = 0
            if timestamp:
                ts = globalClockDelta.localElapsedTime(timestamp)
            ammo.setIval(s, start=True, offset=ts)

        return
コード例 #37
0
    def createGui(self):
        itemId = self.data[0]
        self.itemCount += 1
        self.itemQuantity = self.quantity
        self.itemCost = self.price
        self.picture = DirectFrame(parent=self,
                                   relief=None,
                                   state=DGG.DISABLED,
                                   pos=(0.035000000000000003, 0,
                                        0.025000000000000001))
        self.quantityLabel = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            text=str(self.quantity),
            text_fg=PiratesGuiGlobals.TextFG2,
            text_scale=PiratesGuiGlobals.TextScaleSmall *
            PLocalizer.getHeadingScale(2),
            text_align=TextNode.ARight,
            text_wordwrap=11,
            pos=(0.1225, 0, 0.014999999999999999))
        if len(self.name) >= 39:
            textScale = PiratesGuiGlobals.TextScaleMicro * PLocalizer.getHeadingScale(
                2)
        elif len(self.name) >= 35:
            textScale = PiratesGuiGlobals.TextScaleTiny * PLocalizer.getHeadingScale(
                2)
        else:
            textScale = PiratesGuiGlobals.TextScaleSmall * PLocalizer.getHeadingScale(
                2)
        self.nameTag = DirectLabel(parent=self,
                                   relief=None,
                                   state=DGG.DISABLED,
                                   text=self.name,
                                   text_fg=PiratesGuiGlobals.TextFG2,
                                   text_scale=textScale,
                                   text_align=TextNode.ALeft,
                                   pos=(0.13, 0, 0.014999999999999999))
        self.costText = DirectLabel(
            parent=self,
            relief=None,
            state=DGG.DISABLED,
            image=InventoryListItem.coinImage,
            image_scale=0.12,
            image_pos=Vec3(-0.0050000000000000001, 0, 0.012500000000000001),
            text=str(self.price),
            text_fg=PiratesGuiGlobals.TextFG2,
            text_scale=PiratesGuiGlobals.TextScaleSmall,
            text_align=TextNode.ARight,
            text_wordwrap=11,
            text_pos=(-0.029999999999999999, 0, 0),
            pos=(self.width - 0.035000000000000003, 0, 0.014999999999999999),
            text_font=PiratesGlobals.getInterfaceFont())
        itemClass = EconomyGlobals.getItemCategory(itemId)
        itemType = EconomyGlobals.getItemType(itemId)
        if itemType == ItemType.FISHING_ROD or itemType == ItemType.FISHING_LURE:
            asset = EconomyGlobals.getItemIcons(itemId)
            if asset:
                self.picture['geom'] = PurchaseListItem.fishingIcons.find(
                    '**/%s*' % asset)
                self.picture['geom_scale'] = 0.040000000000000001
                self.picture['geom_pos'] = (0, 0, 0)

        elif itemClass == ItemType.WEAPON or itemClass == ItemType.POUCH:
            asset = EconomyGlobals.getItemIcons(itemId)
            if asset:
                self.picture['geom'] = InventoryListItem.weaponIcons.find(
                    '**/%s*' % asset)
                self.picture['geom_scale'] = 0.040000000000000001
                self.picture['geom_pos'] = (0, 0, 0)

        elif itemClass == ItemType.CONSUMABLE:
            asset = EconomyGlobals.getItemIcons(itemId)
            if asset:
                self.picture['geom'] = InventoryListItem.skillIcons.find(
                    '**/%s*' % asset)
                self.picture['geom_scale'] = 0.040000000000000001
                self.picture['geom_pos'] = (0, 0, 0)

        if not InventoryType.begin_WeaponCannonAmmo <= itemId or itemId <= InventoryType.end_WeaponCannonAmmo:
            if (InventoryType.begin_WeaponPistolAmmo <= itemId
                    or itemId <= InventoryType.end_WeaponGrenadeAmmo
                    or InventoryType.begin_WeaponDaggerAmmo <= itemId
                ) and itemId <= InventoryType.end_WeaponDaggerAmmo:
                skillId = WeaponGlobals.getSkillIdForAmmoSkillId(itemId)
                if skillId:
                    asset = WeaponGlobals.getSkillIcon(skillId)
                    if asset:
                        self.picture[
                            'geom'] = InventoryListItem.skillIcons.find(
                                '**/%s' % asset)
                        self.picture['geom_scale'] = 0.059999999999999998
                        self.picture['geom_pos'] = (0, 0, 0)

            elif InventoryType.SmallBottle <= itemId and itemId <= InventoryType.LargeBottle:
                self.picture['geom'] = self.topGui.find(
                    '**/main_gui_ship_bottle')
                self.picture['geom_scale'] = 0.10000000000000001
                self.picture['geom_pos'] = (0, 0, 0)

        self.flattenStrong()
コード例 #38
0
ファイル: SkillPage.py プロジェクト: Kealigal/POS2013
    def update(self, repId=None, fromUser=0):
        inv = localAvatar.getInventory()
        if not inv:
            self.notify.warning('SkillPage unable to find inventory')
            return
        if self.tabBar == None:
            return
        if self.demo:
            return
        if fromUser:
            self.lastUserSelectedTab = repId
        if repId == None:
            if localAvatar.getGameState() == 'Fishing':
                if self.lastUserSelectedTab:
                    repId = self.lastUserSelectedTab
                else:
                    repId = InventoryType.CannonRep
            elif localAvatar.cannon:
                repId = InventoryType.CannonRep
            elif localAvatar.gameFSM.state == 'ShipPilot':
                repId = InventoryType.SailingRep
            elif localAvatar.currentWeaponId and localAvatar.isWeaponDrawn:
                repId = WeaponGlobals.getRepId(localAvatar.currentWeaponId)
            elif localAvatar.currentWeaponId and not localAvatar.isWeaponDrawn and self.lastUserSelectedTab:
                repId = self.lastUserSelectedTab
            else:
                repId = InventoryType.CannonRep
        self.setRep(repId)
        self.tabBar.selectTab(str(repId))
        self.repMeter.setCategory(repId)
        self.repMeter.update(inv.getReputation(repId))
        unSpentId = self.getUnspent()
        amt = inv.getStackQuantity(unSpentId)
        if unSpentId in self.localMods:
            amt = self.localMods[unSpentId]
        self.unspent['text'] = PLocalizer.SkillPageUnspentPoints % amt
        if amt > 0:
            self.unspent['text_fg'] = (0.8, 1, 0.8, 1)
        else:
            self.unspent['text_fg'] = (1, 1, 1, 1)
        comboSkills = RadialMenu.ComboSkills(repId, 1)
        totalComboSkills = RadialMenu.ComboSkills(repId, 0)
        activeSkills = RadialMenu.ActiveSkills(repId, 1)
        totalActiveSkills = RadialMenu.ActiveSkills(repId, 0)
        passiveSkills = RadialMenu.PassiveSkills(repId, 1)
        totalPassiveSkills = RadialMenu.PassiveSkills(repId, 0)
        self.linkedSkillIds = {}
        linkedSkills = ItemGlobals.getLinkedSkills(localAvatar.currentWeaponId)
        if linkedSkills:
            for skillId in linkedSkills:
                realSkillId = WeaponGlobals.getLinkedSkillId(skillId)
                self.linkedSkillIds[realSkillId] = skillId

        for excludedSkillId in self.EXCLUDED_SKILLS:
            for skillId in activeSkills:
                if excludedSkillId == skillId:
                    activeSkills.remove(skillId)
                    totalActiveSkills.remove(skillId)

        for spot in self.skillFrames.keys():
            if spot not in totalComboSkills:
                self.skillFrames[spot].hide()

        count = 0
        for skill in totalComboSkills:
            skillPts = inv.getStackQuantity(skill)
            if skill in self.localMods:
                skillPts = self.localMods[skill]
            showIcon = skill in comboSkills or skillPts > 0
            freeLock = False
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                if not WeaponGlobals.canFreeUse(skill):
                    freeLock = True
            if self.linkedSkillIds.has_key(skill):
                if self.skillFrames.has_key(skill):
                    self.skillFrames[skill].hide()
                skill = self.linkedSkillIds[skill]
            self.createFrame(skill, skillPts, amt, freeLock, showIcon)
            x = 0.2 + 0.175 * count
            y = 1.11
            self.skillFrames[skill].setPos(x, 0, y)
            if showIcon and skillPts > 1:
                self.makeBoostDisplay(skill, skillPts - 1)
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                if not WeaponGlobals.canFreeUse(skill):
                    self.skillFrames[skill].skillButton[
                        'command'] = base.localAvatar.guiMgr.showNonPayer
                    self.skillFrames[skill].skillButton['extraArgs'] = [
                        'Restricted_Skill_' +
                        WeaponGlobals.getSkillName(skill), 5
                    ]
            count += 1

        count = 0
        for skill in totalActiveSkills:
            skillPts = inv.getStackQuantity(skill)
            if skill in self.localMods:
                skillPts = self.localMods[skill]
            xMod, yMod = self.ringOffset(count)
            xMod *= 0.9
            yMod *= 0.9
            showIcon = skill in activeSkills or skillPts > 0
            freeLock = False
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                if not WeaponGlobals.canFreeUse(skill):
                    freeLock = True
            if self.linkedSkillIds.has_key(skill):
                if self.skillFrames.has_key(skill):
                    self.skillFrames[skill].hide()
                skill = self.linkedSkillIds[skill]
            self.createFrame(skill, skillPts, amt, freeLock, showIcon)
            x = xMod + 0.53
            y = yMod + 0.615
            self.skillFrames[skill].setPos(x, 0, y)
            if showIcon and skillPts > 1:
                self.makeBoostDisplay(skill, skillPts - 1)
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                if not WeaponGlobals.canFreeUse(skill):
                    self.skillFrames[skill].skillButton[
                        'command'] = base.localAvatar.guiMgr.showNonPayer
                    self.skillFrames[skill].skillButton['extraArgs'] = [
                        'Restricted_Skill_' +
                        WeaponGlobals.getSkillName(skill), 5
                    ]
            ammo = self.getAmmo(skill)
            if ammo != None and showIcon:
                self.skillFrames[skill].showQuantity = True
                self.skillFrames[skill].updateQuantity(ammo)
            count += 1

        count = 0
        for skill in totalPassiveSkills:
            skillPts = inv.getStackQuantity(skill)
            if skill in self.localMods:
                skillPts = self.localMods[skill]
            showIcon = skill in passiveSkills or skillPts > 0
            freeLock = False
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                if not WeaponGlobals.canFreeUse(skill):
                    freeLock = True
            if self.linkedSkillIds.has_key(skill):
                if self.skillFrames.has_key(skill):
                    self.skillFrames[skill].hide()
                skill = self.linkedSkillIds[skill]
            self.createFrame(skill, skillPts, amt, freeLock, showIcon)
            x = 0.2 + 0.175 * count
            y = 0.15
            self.skillFrames[skill].setPos(x, 0, y)
            if showIcon and skillPts > 1:
                self.makeBoostDisplay(skill, skillPts - 1)
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                if not WeaponGlobals.canFreeUse(skill):
                    self.skillFrames[skill].skillButton[
                        'command'] = base.localAvatar.guiMgr.showNonPayer
                    self.skillFrames[skill].skillButton['extraArgs'] = [
                        'Restricted_Skill_' +
                        WeaponGlobals.getSkillName(skill), 5
                    ]
            count += 1

        self.dataChanged = False
        return
コード例 #39
0
 def aimOverTargetTask(self, task):
     if base.localAvatar.hasStickyTargets():
         if isinstance(base.localAvatar.currentWeapon, Doll.Doll):
             target = base.localAvatar.currentTarget
             if target:
                 pt = self.getNearProjectionPoint(target)
                 (pt, distance) = self.getTargetScreenXY(target)
                 self.reticleHolder.setPos(pt)
                 self.reticle.setScale(self.reticleScale / distance)
             else:
                 self.reticleHolder.setPos(self.RETICLE_POS)
                 self.reticle.setScale(self.reticleScale)
         
         return Task.cont
     
     (target, dist) = self.takeAim(base.localAvatar)
     if target:
         monstrous = target.hasNetPythonTag('MonstrousObject')
     else:
         monstrous = False
     dt = globalClock.getDt()
     dt = min(1.0, 8 * dt)
     if self.wantAimAssist and target and not monstrous:
         pt = self.getNearProjectionPoint(target)
         (pt, distance) = self.getTargetScreenXY(target)
         rPos = self.reticleHolder.getPos()
         if not rPos.almostEqual(pt, 0.001):
             nPos = Vec3(rPos)
             nPos += (pt - rPos) * dt
             self.reticleHolder.setPos(nPos)
         
         rScale = self.reticle.getScale()
         if not rScale.almostEqual(Vec3(self.reticleScale), 0.001):
             nScale = Vec3(rScale)
             f = self.reticleScale / distance
             nScale += (Vec3(f, f, f) - rScale) * dt
             nScale.setX(max(self.reticleScale / 1.25, nScale[0]))
             nScale.setY(max(self.reticleScale / 1.25, nScale[1]))
             nScale.setZ(max(self.reticleScale / 1.25, nScale[2]))
             self.reticle.setScale(nScale)
         
     else:
         rPos = self.reticleHolder.getPos()
         if not rPos.almostEqual(self.RETICLE_POS, 0.001):
             nPos = Vec3(rPos)
             nPos += (self.RETICLE_POS - rPos) * dt
             self.reticleHolder.setPos(nPos)
             self.reticle.setScale(self.reticleScale)
         
     if target:
         if TeamUtils.damageAllowed(target, localAvatar):
             self.reticle.setColorScale(1, 1, 1, self.reticleAlpha)
             if base.localAvatar.currentWeapon:
                 repId = WeaponGlobals.getRepId(base.localAvatar.currentWeaponId)
                 baseRange = self.WeaponBaseRange.get(repId)
                 calcRange = 0
                 specialRange = 0
                 specialMeleeRange = 0
                 ammoSkillId = localAvatar.guiMgr.combatTray.ammoSkillId
                 deadzoneRange = base.cr.battleMgr.getModifiedAttackDeadzone(localAvatar, 0, ammoSkillId)
                 if repId == InventoryType.PistolRep:
                     if localAvatar.guiMgr.combatTray.isCharging:
                         calcRange = base.cr.battleMgr.getModifiedAttackRange(localAvatar, InventoryType.PistolTakeAim, ammoSkillId)
                     else:
                         calcRange = base.cr.battleMgr.getModifiedAttackRange(localAvatar, InventoryType.PistolShoot, ammoSkillId)
                     if ItemGlobals.getSubtype(localAvatar.currentWeaponId) == ItemGlobals.BLUNDERBUSS:
                         baseRange = base.cr.battleMgr.getModifiedAttackRange(localAvatar, EnemySkills.PISTOL_SCATTERSHOT, ammoSkillId)
                         calcRange = base.cr.battleMgr.getModifiedAttackRange(localAvatar, EnemySkills.PISTOL_SCATTERSHOT, ammoSkillId)
                     elif ItemGlobals.getSubtype(localAvatar.currentWeaponId) == ItemGlobals.MUSKET:
                         specialRange = base.cr.battleMgr.getModifiedAttackRange(localAvatar, EnemySkills.PISTOL_DEADEYE, ammoSkillId)
                     elif ItemGlobals.getSubtype(localAvatar.currentWeaponId) == ItemGlobals.BAYONET:
                         specialMeleeRange = base.cr.battleMgr.getModifiedAttackRange(localAvatar, EnemySkills.BAYONET_RUSH, 0)
                     
                 elif repId == InventoryType.DaggerRep:
                     calcRange = base.cr.battleMgr.getModifiedAttackRange(localAvatar, InventoryType.DaggerAsp, 0)
                 elif repId == InventoryType.WandRep:
                     if ammoSkillId:
                         calcRange = base.cr.battleMgr.getModifiedAttackRange(localAvatar, ammoSkillId, 0)
                     
                     specialRange = base.cr.battleMgr.getModifiedAttackRange(localAvatar, InventoryType.StaffBlast, 0)
                 
                 distance = dist
                 if hasattr(target, 'battleTubeNodePaths') and not monstrous:
                     for tube in target.battleTubeNodePaths:
                         tubeLength = max(target.battleTubeRadius, target.battleTubeHeight)
                         if distance - tubeLength < distance:
                             distance -= tubeLength
                             continue
                     
                 
                 range = max(baseRange, calcRange)
                 secondaryRange = max(baseRange, specialRange)
                 if distance <= secondaryRange and distance >= deadzoneRange:
                     self.reticle.setColorScale(1, 0.69999999999999996, 0, self.reticleAlpha)
                 
                 if distance <= range and distance >= deadzoneRange:
                     self.reticle.setColorScale(1, 0, 0, self.reticleAlpha)
                 
                 if specialMeleeRange and distance <= specialMeleeRange:
                     self.reticle.setColorScale(1, 0.69999999999999996, 0, self.reticleAlpha)
                 
             
         else:
             self.reticle.setColorScale(0, 0, 1, self.reticleAlpha)
     else:
         self.reticle.setColorScale(1, 1, 1, self.reticleAlpha)
     oldTarget = base.localAvatar.currentAimOver
     if target == oldTarget:
         return Task.cont
     
     if oldTarget != None:
         messenger.send(oldTarget.uniqueName('aimOver'), [
             0])
         base.localAvatar.currentAimOver = None
         oldTarget.hideEnemyTargetInfo()
     
     if oldTarget != None and not target:
         oldTarget.hideHpMeter(delay = 8.0)
     
     if target and not target.isInvisibleGhost():
         target.showHpMeter()
         if TeamUtils.damageAllowed(target, localAvatar):
             target.showEnemyTargetInfo()
             messenger.send('pistolAimedTarget')
         else:
             target.showFriendlyTargetInfo()
         messenger.send(target.uniqueName('aimOver'), [
             1])
         base.localAvatar.currentAimOver = target
     else:
         base.localAvatar.currentAimOver = None
     return Task.cont
コード例 #40
0
ファイル: SkillPage.py プロジェクト: Kealigal/POS2013
 def addPoint(self, skillId):
     if skillId == InventoryType.SailPowerRecharge:
         return
     inv = localAvatar.getInventory()
     frameSkillId = skillId
     skillId = WeaponGlobals.getLinkedSkillId(frameSkillId)
     if not skillId:
         skillId = frameSkillId
     if self.currentRep == InventoryType.CutlassRep and localAvatar.style.tutorial < PiratesGlobals.TUT_GOT_CUTLASS:
         if inv.getStackQuantity(InventoryType.CutlassSweep) < 2:
             if skillId != InventoryType.CutlassSweep:
                 return
         elif skillId == InventoryType.CutlassSweep:
             messenger.send('skillImprovementAttempted')
     unSpentId = self.getUnspent()
     unSp = inv.getStackQuantity(unSpentId)
     if unSpentId in self.localMods:
         unSp = self.localMods[unSpentId]
     if unSp < 1:
         return
     if inv.getStackLimit(skillId):
         curAmt = inv.getStackQuantity(skillId)
         if skillId in self.localMods:
             curAmt = self.localMods[skillId]
         if curAmt > 5:
             return
         else:
             curAmt += 1
     else:
         return
     self.__handleFreeDialog()
     if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
         if curAmt > Freebooter.FreeSkillCap:
             self.spentDialog = PDialog.PDialog(
                 text=PLocalizer.FreebooterSkillMax,
                 style=OTPDialog.CancelOnly,
                 command=self.__handleFreeDialog)
             return
         playerExp = inv.getAccumulator(self.currentRep)
         categoryLevel, extra = ReputationGlobals.getLevelFromTotalReputation(
             self.currentRep, playerExp)
         alreadySpent = categoryLevel - 1 - unSp
         if alreadySpent > 5:
             self.spentDialog = PDialog.PDialog(
                 text=PLocalizer.FreebooterSkillLock,
                 style=OTPDialog.CancelOnly,
                 command=self.__handleFreeDialog)
             return
     if not base.config.GetBool('want-combo-skips', 0):
         comboSkills = [
             InventoryType.CutlassSlash, InventoryType.CutlassCleave,
             InventoryType.CutlassFlourish, InventoryType.CutlassStab,
             InventoryType.DaggerSwipe, InventoryType.DaggerGouge,
             InventoryType.DaggerEviscerate
         ]
         if skillId in comboSkills and inv.getStackQuantity(skillId -
                                                            1) <= 1:
             base.localAvatar.guiMgr.createWarning(
                 PLocalizer.ComboOrderWarn, PiratesGuiGlobals.TextFG6)
             return
     messenger.send('skillImprovementAttempted')
     localAvatar.spendSkillPoint(skillId)
     self.localMods[skillId] = curAmt
     self.localMods[unSpentId] = unSp - 1
     self.skillFrames[frameSkillId].skillRank = curAmt - 1
コード例 #41
0
ファイル: SkillPage.py プロジェクト: Kealigal/POS2013
    def respec(self, weaponRep):
        listReset1 = WeaponGlobals.StartingSkills
        begin = -1
        end = -1
        unSpentId = -1
        if weaponRep == InventoryType.CutlassRep:
            begin = InventoryType.begin_WeaponSkillCutlass
            end = InventoryType.end_WeaponSkillCutlass
            unSpentId = InventoryType.UnspentCutlass
        else:
            if weaponRep == InventoryType.PistolRep:
                begin = InventoryType.begin_WeaponSkillPistol
                end = InventoryType.end_WeaponSkillPistol
                unSpentId = InventoryType.UnspentPistol
            else:
                if weaponRep == InventoryType.DaggerRep:
                    begin = InventoryType.begin_WeaponSkillDagger
                    end = InventoryType.end_WeaponSkillDagger
                    unSpentId = InventoryType.UnspentDagger
                elif weaponRep == InventoryType.GrenadeRep:
                    begin = InventoryType.begin_WeaponSkillGrenade
                    end = InventoryType.end_WeaponSkillGrenade
                    unSpentId = InventoryType.UnspentGrenade
                elif weaponRep == InventoryType.DollRep:
                    begin = InventoryType.begin_WeaponSkillDoll
                    end = InventoryType.end_WeaponSkillDoll
                    unSpentId = InventoryType.UnspentDoll
                elif weaponRep == InventoryType.WandRep:
                    begin = InventoryType.begin_WeaponSkillWand
                    end = InventoryType.end_WeaponSkillWand
                    unSpentId = InventoryType.UnspentWand
                elif weaponRep == InventoryType.SailingRep:
                    begin = InventoryType.begin_SkillSailing
                    end = InventoryType.end_SkillSailing
                    unSpentId = InventoryType.UnspentSailing
                elif weaponRep == InventoryType.CannonRep:
                    begin = InventoryType.begin_WeaponSkillCannon
                    end = InventoryType.end_WeaponSkillCannon
                    unSpentId = InventoryType.UnspentCannon
                else:
                    return
                inv = localAvatar.getInventory()
                extra = 0
                for skillId in range(begin, end):
                    if skillId in WeaponGlobals.DontResetSkills:
                        continue
                    curAmt = inv.getStackQuantity(skillId)
                    if skillId in self.localMods:
                        curAmt = self.localMods[skillId]
                    resetAmt = 1
                    if skillId in listReset1:
                        resetAmt = 2
                    if curAmt > resetAmt:
                        extra += curAmt - resetAmt
                        self.localMods[skillId] = resetAmt
                        if self.tabBar and skillId in self.skillFrames:
                            self.skillFrames[skillId].skillRank = resetAmt - 1
                        if self.tabBar:
                            if resetAmt > 1:
                                self.makeBoostDisplay(skillId, resetAmt - 1)
                            else:
                                self.removeBoostDisplay(skillId)
                        for linkedSkills in ItemGlobals.LinkedSkills.values():
                            for linkedSkillId in linkedSkills:
                                if skillId == WeaponGlobals.getLinkedSkillId(
                                        linkedSkillId):
                                    if self.tabBar and linkedSkillId in self.skillFrames:
                                        self.skillFrames[
                                            linkedSkillId].skillRank = resetAmt - 1
                                    if self.tabBar:
                                        if resetAmt > 1:
                                            self.makeBoostDisplay(
                                                linkedSkillId, resetAmt - 1)
                                        else:
                                            self.removeBoostDisplay(
                                                linkedSkillId)

            if unSpentId in self.localMods:
                self.localMods[unSpentId] += extra
コード例 #42
0
    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
        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*')
        SkillIcons = loader.loadModel('models/textureCards/skillIcons')
        border = 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.TextFG24
        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=PLocalizer.InventoryItemClassNames.get(
                EconomyGlobals.getItemType(self.getId()), ''),
            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)
        self.iconLabel = DirectLabel(
            parent=self.portraitSceneGraph,
            relief=None,
            image=SkillIcons.find(
                '**/%s' % WeaponGlobals.getSkillIcon(self.getSkillId())),
            pos=(0.0, 2.5, 0.0))
        iHeight = 0.18
        self.createBuffer()
        self.itemCard.setZ(runningVertPosition - 0.06)
        runningVertPosition -= iHeight
        runningSize += iHeight
        labels.append(self.itemCard)
        description = PLocalizer.WeaponDescriptions.get(self.getId())
        if not description:
            description = PLocalizer.WeaponDescriptions.get(self.getSkillId())
        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)
        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)
        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)
        if basePosZ > 0.0:
            newPosZ = basePosZ + cellSizeZ * 0.45
        else:
            newPosZ = basePosZ + totalHeight - cellSizeZ * 0.75
        if detailsPos:
            newPosX, newPosZ = detailsPos
        self.helpFrame.setPos(newPosX, 0, newPosZ)
        return
コード例 #43
0
    }],
    'level':
    20,
    'free':
    False,
    'discovered':
    False
}, {
    'name':
    PLocalizer.InventoryTypeNames[InventoryType.CannonDamageLvl1],
    'desc':
    PLocalizer.PotionDescs[InventoryType.CannonDamageLvl1].safe_substitute({
        '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,
コード例 #44
0
ファイル: PVPGlobals.py プロジェクト: rasheelprogrammer/potco
ShipRegenHps = StateVarSetting('pvp.shipHeal.island.healPerSecHP', 50)
ShipRegenSps = StateVarSetting('pvp.shipHeal.island.healPerSecSP', 50)
ShipRegenPeriod = StateVarSetting('pvp.shipHeal.island.healPeriodSecs', 2)
RepairRate = StateVarSetting('pvp.shipHeal.repairSpots.repairRate', 10.0)
RepairRateMultipliers = StateVarSetting('pvp.shipHeal.repairSpots.repairRateMultipliers', [
    1.0,
    2.0,
    3.0,
    4.0])
RepairAcceleration = StateVarSetting('pvp.shipHeal.repairSpots.repairAcceleration', 2)
RepairAccelerationMultipliers = StateVarSetting('pvp.shipHeal.repairSpots.repairAccelerationMultipliers', [
    1.0,
    1.0,
    1.0,
    1.0])
RepairKitHp = StateVarSetting('pvp.shipHeal.repairKit.HP', WeaponGlobals.getAttackHullHP(InventoryType.ShipRepairKit))
RepairKitSp = StateVarSetting('pvp.shipHeal.repairKit.SP', WeaponGlobals.getAttackSailHP(InventoryType.ShipRepairKit))
SinkHpBonusPercent = StateVarSetting('pvp.sinkBonus.hp.percent', 0.80000000000000004)
SinkStreakPeriod = StateVarSetting('pvp.announcements.sinkStreakPeriod', 5)

def updateRepairKitHp(hp):
    WeaponGlobals.__skillInfo[InventoryType.ShipRepairKit][WeaponGlobals.HULL_HP_INDEX] = hp


def updateRepairKitSp(sp):
    WeaponGlobals.__skillInfo[InventoryType.ShipRepairKit][WeaponGlobals.SAIL_HP_INDEX] = sp

UpdateRepairKitHp = FunctionCall(updateRepairKitHp, RepairKitHp)
UpdateRepairKitHp.pushCurrentState()
UpdateRepairKitSp = FunctionCall(updateRepairKitSp, RepairKitSp)
UpdateRepairKitSp.pushCurrentState()
コード例 #45
0
    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)
        shipBoost = 0
        if localAvatar.ship:
            shipBoost = localAvatar.ship.getSkillBoost(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 = '\x1red\x1'
            if rank == 0:
                color = '\x1red\x1'
                upgradeInfo = ''
            
            description += '\n' + color + SkillComboReq[self.skillId] + '.'
        
        skillDesc = skillTitle + '\n' + skillType + '\n\n' + description + '\n\x1green\x1' + upgradeInfo + '\x2'
        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 + shipBoost), 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 = tuple(lambda [outmost-iterable]: for stat in [outmost-iterable]:
stat + 0.01(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)
コード例 #46
0
def getGeomScale(repId, skillId = 0):
    if repId == InventoryType.PistolRep and WeaponGlobals.getSkillType(skillId) == WeaponGlobals.AMMO_SKILL:
        return 0.17999999999999999
    else:
        return 0.12
コード例 #47
0
 def playAttack(self,
                skillId,
                ammoSkillId,
                pos=0,
                startVel=0,
                targetPos=None,
                flightTime=0):
     if not WeaponGlobals.isProjectileSkill(skillId, ammoSkillId):
         if self.localAvatarUsingWeapon:
             localAvatar.composeRequestTargetedSkill(skillId, ammoSkillId)
         return
     self.ammoSequence = self.ammoSequence + 1 & 255
     buffs = []
     if self.av:
         buffs = self.av.getSkillEffects()
     ammo = self.getProjectile(ammoSkillId, self.projectileHitEvent, buffs)
     ammo.setPos(pos)
     if skillId == EnemySkills.LEFT_BROADSIDE:
         ammo.setH(render, self.ship.getH(render) + 90)
     elif skillId == EnemySkills.RIGHT_BROADSIDE:
         ammo.setH(render, self.ship.getH(render) - 90)
     collNode = ammo.getCollNode()
     collNode.reparentTo(render)
     ammo.setTag('ammoSequence', str(self.ammoSequence))
     ammo.setTag('skillId', str(int(skillId)))
     ammo.setTag('ammoSkillId', str(int(ammoSkillId)))
     if self.av:
         ammo.setTag('attackerId', str(self.av.doId))
     startPos = pos
     endPlaneZ = -10
     if self.ship:
         ammo.setTag('shipId', str(self.ship.doId))
         self.shotNum += 1
         if self.shotNum > 100000:
             self.shotNum = 0
         ammo.setTag('shotNum', str(self.shotNum))
         self.baseVel = self.ship.worldVelocity
     if startPos[2] < endPlaneZ:
         self.notify.warning('bad startPos Z: %s' % startPos[2])
         return
     if targetPos is None:
         startVel += self.baseVel
         pi = ProjectileInterval(ammo,
                                 startPos=startPos,
                                 startVel=startVel,
                                 endZ=endPlaneZ,
                                 gravityMult=2.0,
                                 collNode=collNode)
     else:
         if self.ship.getNPCship():
             pi = ProjectileInterval(ammo,
                                     endZ=endPlaneZ,
                                     startPos=startPos,
                                     wayPoint=targetPos,
                                     timeToWayPoint=flightTime,
                                     gravityMult=0.5,
                                     collNode=collNode)
         else:
             pi = ProjectileInterval(ammo,
                                     endZ=endPlaneZ,
                                     startPos=startPos,
                                     wayPoint=targetPos,
                                     timeToWayPoint=flightTime,
                                     gravityMult=1.2,
                                     collNode=collNode)
         if base.cr.cannonballCollisionDebug == 1 or base.cr.cannonballCollisionDebug == 2:
             addFunc = Func(base.cTrav.addCollider, collNode,
                            ammo.collHandler)
             delFunc = Func(base.cTrav.removeCollider, collNode)
         addFunc = Wait(0)
         delFunc = Wait(0)
     s = Parallel(Sequence(Wait(0.1), addFunc),
                  Sequence(pi, Func(ammo.destroy), delFunc))
     ammo.setIval(s, start=True)
     return
コード例 #48
0
ファイル: StoreGUI.py プロジェクト: tiideinmaar/POTCO-PS
    def handleBuyItem(self, data, useCode):
        itemId = data[0]
        if not itemId:
            return None

        itemType = EconomyGlobals.getItemType(itemId)
        if itemType <= ItemType.WAND or itemType == ItemType.POTION:
            data[1] = 1
        else:
            data[1] = EconomyGlobals.getItemQuantity(itemId)
        inventory = base.localAvatar.getInventory()
        if not inventory:
            return None

        itemQuantity = self.purchaseInventory.getItemQuantity(itemId)
        currStock = inventory.getStackQuantity(itemId)
        currStockLimit = inventory.getStackLimit(itemId)
        if useCode == PiratesGuiGlobals.InventoryAdd:
            itemTypeName = PLocalizer.InventoryItemClassNames.get(itemType)
            trainingReq = EconomyGlobals.getItemTrainingReq(itemId)
            if trainingReq:
                amt = inventory.getStackQuantity(trainingReq)
                if not amt:
                    base.localAvatar.guiMgr.createWarning(
                        PLocalizer.NoTrainingWarning % itemTypeName,
                        PiratesGuiGlobals.TextFG6)
                    return None

            itemType = EconomyGlobals.getItemType(itemId)
            if itemType != ItemType.POTION:
                minLvl = ItemGlobals.getWeaponRequirement(itemId)
            else:
                minLvl = 0
            repId = WeaponGlobals.getRepId(itemId)
            repAmt = inventory.getAccumulator(repId)
            if minLvl > ReputationGlobals.getLevelFromTotalReputation(
                    repId, repAmt)[0]:
                base.localAvatar.guiMgr.createWarning(
                    PLocalizer.LevelReqWarning % (minLvl, itemTypeName),
                    PiratesGuiGlobals.TextFG6)
                return None

            if itemId in ItemGlobals.getAllWeaponIds():
                locatables = []
                for dataInfo in self.purchaseInventory.inventory:
                    dataId = dataInfo[0]
                    if dataId in ItemGlobals.getAllWeaponIds():
                        locatables.append(
                            InvItem([InventoryType.ItemTypeWeapon, dataId, 0]))
                        continue

                locatables.append(
                    InvItem([InventoryType.ItemTypeWeapon, itemId, 0]))
                locationIds = inventory.canAddLocatables(locatables)
                for locationId in locationIds:
                    if locationId in (Locations.INVALID_LOCATION,
                                      Locations.NON_LOCATION):
                        base.localAvatar.guiMgr.createWarning(
                            PLocalizer.InventoryFullWarning,
                            PiratesGuiGlobals.TextFG6)
                        return None
                        continue

            elif itemId in ItemGlobals.getAllConsumableIds():
                itemQuantity = self.purchaseInventory.getItemQuantity(itemId)
                currStock = inventory.getItemQuantity(
                    InventoryType.ItemTypeConsumable, itemId)
                currStockLimit = inventory.getItemLimit(
                    InventoryType.ItemTypeConsumable, itemId)
                if currStock + itemQuantity >= currStockLimit:
                    base.localAvatar.guiMgr.createWarning(
                        PLocalizer.TradeItemFullWarning,
                        PiratesGuiGlobals.TextFG6)
                    return None

                if currStock == 0:
                    locatables = []
                    dataIds = {}
                    for dataInfo in self.purchaseInventory.inventory:
                        dataId = dataInfo[0]
                        if dataId in ItemGlobals.getAllConsumableIds():
                            if dataIds.has_key(dataId):
                                dataIds[dataId] += 1
                            else:
                                dataIds[dataId] = 1
                        dataIds.has_key(dataId)

                    if dataIds.has_key(itemId):
                        dataIds[itemId] += 1
                    else:
                        dataIds[itemId] = 1
                    for dataId in dataIds:
                        locatables.append(
                            InvItem([
                                InventoryType.ItemTypeConsumable, dataId, 0,
                                dataIds[dataId]
                            ]))

                    locationIds = inventory.canAddLocatables(locatables)
                    for locationId in locationIds:
                        if locationId in (Locations.INVALID_LOCATION,
                                          Locations.NON_LOCATION):
                            base.localAvatar.guiMgr.createWarning(
                                PLocalizer.InventoryFullWarning,
                                PiratesGuiGlobals.TextFG6)
                            return None
                            continue

            else:
                itemQuantity = self.purchaseInventory.getItemQuantity(itemId)
                currStock = inventory.getStackQuantity(itemId)
                currStockLimit = inventory.getStackLimit(itemId)
                itemCategory = EconomyGlobals.getItemCategory(itemId)
                if currStock + itemQuantity >= currStockLimit:
                    base.localAvatar.guiMgr.createWarning(
                        PLocalizer.TradeItemFullWarning,
                        PiratesGuiGlobals.TextFG6)
                    return None

            self.purchaseInventory.addPanel(data)
            self.purchaseInventory.inventory.append(data)
        elif useCode == PiratesGuiGlobals.InventoryRemove:
            self.purchaseInventory.removePanel(data)

        panel = self.storeInventory.getPanel(data)
        if panel:
            self.checkPanel(panel, inventory, itemId)

        self.updateBalance()
コード例 #49
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()
コード例 #50
0
    def useTargetedSkill(self,
                         skillId,
                         ammoSkillId,
                         skillResult,
                         targetId,
                         areaIdList,
                         attackerEffects,
                         targetEffects,
                         areaIdEffects,
                         itemEffects,
                         timestamp,
                         pos,
                         charge=0,
                         localSignal=0):
        if WeaponGlobals.isSelfUseSkill(skillId):
            if not localSignal:
                selfUse = True
            else:
                selfUse = False
            if localSignal:
                target = self.cr.doId2do.get(targetId)
                if target:
                    if target != self and WeaponGlobals.isBreakAttackComboSkill(
                            skillId
                    ) and skillResult == WeaponGlobals.RESULT_HIT:
                        levelGrade = self.cr.battleMgr.getModifiedExperienceGrade(
                            self, target)
                        self.guiMgr.combatTray.updateSkillCharges(levelGrade)
                multiHits = (not self.isLocal() or localSignal
                             or WeaponGlobals.getSkillTrack(skillId)
                             == WeaponGlobals.DEFENSE_SKILL_INDEX
                             or selfUse) and []
                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:
                        if areaIdList:
                            self.playSkillMovie(skillId, ammoSkillId,
                                                skillResult, charge,
                                                areaIdList[0], areaIdList)
                        else:
                            self.playSkillMovie(skillId, ammoSkillId,
                                                skillResult, charge, targetId,
                                                areaIdList)
                    target = (skillResult == WeaponGlobals.RESULT_REFLECTED
                              or selfUse) and self
                    targetId = self.getDoId()
                else:
                    if 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:
                            multiHitEffects = numHits and 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)

                not self.currentTarget and not areaIdList and self.playHitSound(
                    skillId, ammoSkillId, WeaponGlobals.RESULT_MISS)
        return
コード例 #51
0
 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'],
コード例 #52
0
    def __init__(self, inventoryUIManager):
        self.inventoryUIManager = inventoryUIManager
        InventoryPage.InventoryPage.__init__(self)
        self.initialiseoptions(InventoryBagPage)
        self.containerList = []
        self.containersToShowTrash = []
        self.treasureTab = None
        self.isReady = 0
        self.treasurePageReopen = 0
        self.openedContainer = None
        self.redeemCodeGUI = None
        self.buttonSize = self.inventoryUIManager.standardButtonSize
        self.weaponBag = self.addContainer(
            InventoryUIWeaponContainer.InventoryUIWeaponContainer(
                self.inventoryUIManager,
                self.buttonSize * 6.0,
                self.buttonSize * 5.0,
                6,
                5,
                slotList=range(Locations.RANGE_WEAPONS[0],
                               Locations.RANGE_WEAPONS[0] + 30)))
        self.clothingBag = self.addContainer(
            InventoryUIClothingContainer.InventoryUIClothingContainer(
                self.inventoryUIManager,
                self.buttonSize * 5.0,
                self.buttonSize * 7.0,
                5,
                7,
                slotList=range(Locations.RANGE_CLOTHES[0],
                               Locations.RANGE_CLOTHES[0] + 35)))
        self.jewelryBag = self.addContainer(
            InventoryUIJewelryContainer.InventoryUIJewelryContainer(
                self.inventoryUIManager,
                self.buttonSize * 4.0,
                self.buttonSize * 7.0,
                4,
                7,
                slotList=range(Locations.RANGE_JEWELERY_AND_TATTOO[0],
                               Locations.RANGE_JEWELERY_AND_TATTOO[0] + 28)))
        cardRange = range(UberDogGlobals.InventoryType.begin_Cards,
                          UberDogGlobals.InventoryType.end_Cards)
        cardRange.reverse()
        self.potionBag = self.addContainer(
            InventoryUIConsumableContainerLocatable.
            InventoryUIConsumableContainerLocatable(
                self.inventoryUIManager,
                self.buttonSize * 6.0,
                self.buttonSize * 7.0,
                6,
                7,
                slotList=range(Locations.RANGE_CONSUMABLE[0],
                               Locations.RANGE_CONSUMABLE[0] + 42)))
        self.ammoBag = self.addContainer(
            InventoryUIAmmoContainer.InventoryUIAmmoContainer(
                self.inventoryUIManager,
                self.buttonSize * 7.0,
                self.buttonSize * 6.0,
                maxCountX=7,
                itemList=WeaponGlobals.getAllAmmoSkills()),
            showTrash=0)
        self.materialBag = self.addContainer(
            InventoryUIMaterialContainer.InventoryUIMaterialContainer(
                self.inventoryUIManager,
                self.buttonSize * 7.0,
                self.buttonSize * 6.0,
                maxCountX=7,
                itemList=WeaponGlobals.getAllAmmoSkills()),
            showTrash=0)
        self.cardBag = self.addContainer(
            InventoryUICardContainer.InventoryUICardContainer(
                self.inventoryUIManager,
                self.buttonSize * 4.0,
                self.buttonSize * 13.0,
                4,
                13,
                minCountZ=13,
                maxCountX=4,
                itemList=cardRange),
            showTrash=0)
        hotkeySlotStart = Locations.RANGE_EQUIP_WEAPONS[0]
        weaponKeySlotList = []
        for weaponIndex in range(Locations.RANGE_EQUIP_WEAPONS[0],
                                 Locations.RANGE_EQUIP_WEAPONS[1] + 1):
            weaponKeySlotList.append(
                ('F%s' % weaponIndex, 'f%s' % weaponIndex, weaponIndex))

        weaponKeySlotList.append((PLocalizer.InventoryPageItemSlot, '',
                                  Locations.RANGE_EQUIP_ITEMS[0]))
        self.inventoryPanelHotkey = InventoryUIBeltGrid.InventoryUIBeltGrid(
            self.inventoryUIManager,
            self.buttonSize * float(len(weaponKeySlotList)), self.buttonSize,
            len(weaponKeySlotList), 1, weaponKeySlotList)
        self.inventoryPanelHotkey.setPos(
            0.42499999999999999 - 0.5 * self.inventoryPanelHotkey.sizeX, 0.0,
            0.89500000000000002)
        self.inventoryPanelHotkey.reparentTo(self.weaponBag)
        self.inventoryPanelTrash = InventoryUITrashContainer.InventoryUITrashContainer(
            self.inventoryUIManager, self.buttonSize, self.buttonSize)
        self.inventoryPanelTrash.setup()
        self.inventoryPanelTrash.setPos(0.070000000000000007, 0.0,
                                        -0.029999999999999999)
        self.inventoryPanelTrash.reparentTo(self)
        self.inventoryPanelDrinker = InventoryUIDrinker.InventoryUIDrinker(
            self.inventoryUIManager, self.buttonSize, self.buttonSize)
        self.inventoryPanelDrinker.setup()
        self.inventoryPanelDrinker.setPos(0.29999999999999999, 0.0,
                                          -0.029999999999999999)
        self.inventoryPanelDrinker.reparentTo(self)
        self.inventoryPanelDressing = InventoryUIDressingContainer.InventoryUIDressingContainer(
            self.inventoryUIManager,
            self.buttonSize,
            self.buttonSize * 7.0,
            slotList=range(Locations.RANGE_EQUIP_CLOTHES[0],
                           Locations.RANGE_EQUIP_CLOTHES[1] + 1))
        self.inventoryPanelDressing.setPos(-0.22500000000000001, 0.0, -0.0)
        self.inventoryPanelDressing.reparentTo(self.clothingBag)
        self.inventoryPanelJewelryDressing = InventoryUIJewelryDressingContainer.InventoryUIJewelryDressingContainer(
            self.inventoryUIManager,
            self.buttonSize * 2.0,
            self.buttonSize * 4.0,
            slotList=range(Locations.RANGE_EQUIP_JEWELRY[0],
                           Locations.RANGE_EQUIP_JEWELRY[1] + 1))
        self.inventoryPanelJewelryDressing.setPos(-0.37, 0.0,
                                                  0.40999999999999998)
        self.inventoryPanelJewelryDressing.reparentTo(self.jewelryBag)
        self.inventoryPanelTattooDressing = InventoryUITattooDressingContainer.InventoryUITattooDressingContainer(
            self.inventoryUIManager,
            self.buttonSize * 2.0,
            self.buttonSize * 2.0,
            slotList=range(Locations.RANGE_EQUIP_TATTOO[0],
                           Locations.RANGE_EQUIP_TATTOO[1] + 1))
        self.inventoryPanelTattooDressing.setPos(-0.37, 0.0, 0.0)
        self.inventoryPanelTattooDressing.reparentTo(self.jewelryBag)
        self.inventoryPanelGold = InventoryUIGoldContainer.InventoryUIGoldContainer(
            self.inventoryUIManager, self.buttonSize, self.buttonSize)
        self.inventoryPanelGold.setPos(0.84999999999999998, 0.0,
                                       -0.029999999999999999)
        self.inventoryPanelGold.reparentTo(self)
        self.backTabParent = self.attachNewNode('backTabs')
        self.frontTabParent = self.attachNewNode('frontTab', sort=2)
        self.tabBar = None
        self.tabCount = 0
        for container in self.containerList:
            container.setPos(0.14000000000000001, 0.0, 0.44)
            container.setX(0.54000000000000004 - 0.5 * container.sizeX)
            container.setZ(1.2 - container.getTotalHeight())
            container.reparentTo(self)

        self.weaponBag.setZ(0.20000000000000001)
        self.clothingBag.setPos(self.buttonSize * 2.0 + 0.029999999999999999,
                                0.0, 0.20000000000000001)
        self.jewelryBag.setPos(self.buttonSize * 3.0 + 0.040000000000000001,
                               0.0, 0.20999999999999999)
        self.ammoBag.setPos(self.buttonSize * 0.5 - 0.029999999999999999, 0.0,
                            0.248)
        self.cardBag.setPos(self.buttonSize * 1.5 - 0.02, 0.0,
                            self.buttonSize * 2.0)
        Gui = loader.loadModel('models/gui/char_gui')
        buttonImage = (Gui.find('**/chargui_text_block_large'),
                       Gui.find('**/chargui_text_block_large_down'),
                       Gui.find('**/chargui_text_block_large_over'),
                       Gui.find('**/chargui_text_block_large'))
        self.redeemCodeButton = DirectButton(
            parent=self,
            relief=None,
            image=buttonImage,
            image_scale=0.45000000000000001,
            text=PLocalizer.InventoryRedeemCode,
            text_font=PiratesGlobals.getInterfaceOutlineFont(),
            text_align=TextNode.ACenter,
            text_pos=(0, -0.01),
            text_scale=PiratesGuiGlobals.TextScaleLarge,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            pos=(0.68000000000000005, 0, 0.040000000000000001),
            command=self.showRedeemCodeGUI)
        self.redeemCodeButton.hide()
        self.faceCameraButton = DirectButton(
            parent=self,
            relief=None,
            image=buttonImage,
            image_scale=0.45000000000000001,
            text=PLocalizer.InventoryFaceCamera,
            text_font=PiratesGlobals.getInterfaceOutlineFont(),
            text_align=TextNode.ACenter,
            text_pos=(0, -0.01),
            text_scale=PiratesGuiGlobals.TextScaleLarge,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            pos=(0.37, 0, 0.040000000000000001),
            command=self.faceCamera)
        self.faceCameraButton.hide()
        self.notLoadedWarning = DirectLabel(
            parent=self,
            relief=DGG.SUNKEN,
            borderWidth=(0, 0),
            frameColor=(0.5, 0.14999999999999999, 0.050000000000000003, 1),
            text=PLocalizer.InventoryNotLoaded,
            text_align=TextNode.ALeft,
            text_font=PiratesGlobals.getInterfaceOutlineFont(),
            text_scale=0.044999999999999998,
            text_fg=(1, 1, 1, 1),
            text_wordwrap=20.0,
            state=DGG.DISABLED,
            pos=(0.10000000000000001, 0, 0.75))
        self.accept('openingContainer', self.onOpen)
        self.acceptOnce('localPirate-created', self.askInventory)
        self.accept('pickedUpItem', self.onLocatable)
        self.invRequestId = None
コード例 #53
0
 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(
コード例 #54
0
    def playOuch(self,
                 skillId,
                 ammoSkillId,
                 targetEffects,
                 attacker,
                 pos,
                 itemEffects=[],
                 multihit=0,
                 targetBonus=0,
                 skillResult=0):
        (targetHp, targetPower, targetEffect, targetMojo,
         targetSwiftness) = targetEffects
        if attacker:
            self.addCombo(attacker.getDoId(), attacker.currentWeaponId,
                          skillId, -targetHp)

        self.cleanupOuchIval()
        if not targetBonus:
            if ammoSkillId:
                effectId = WeaponGlobals.getHitEffect(ammoSkillId)
            else:
                effectId = WeaponGlobals.getHitEffect(skillId)

        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'):
                ouchSfx = None
                currentAnim = self.getCurrentAnim()
                if currentAnim == 'run':
                    painAnim = 'run_hit'
                elif currentAnim == 'walk':
                    painAnim = 'walk_hit'
                else:
                    painAnim = 'idle_hit'
                actorIval = self.actorInterval(painAnim,
                                               playRate=random.uniform(
                                                   0.69999999999999996, 1.5))
                if self.currentWeapon and WeaponGlobals.getIsStaffAttackSkill(
                        skillId):
                    skillInfo = WeaponGlobals.getSkillAnimInfo(skillId)
                    getOuchSfxFunc = skillInfo[WeaponGlobals.OUCH_SFX_INDEX]
                    if getOuchSfxFunc:
                        ouchSfx = getOuchSfxFunc()

                else:
                    ouchSfx = self.getSfx('pain')
                if ouchSfx:
                    self.ouchAnim = Sequence(
                        Func(base.playSfx, ouchSfx, node=self, cutoff=75),
                        actorIval)
                else:
                    self.ouchAnim = actorIval
                self.ouchAnim.start()

        if self.combatEffect:
            self.combatEffect.destroy()
            self.combatEffect = None

        self.combatEffect = CombatEffect.CombatEffect(effectId, multihit,
                                                      attacker)
        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 attacker and not attacker.isEmpty():
                self.combatEffect.lookAt(attacker)

            self.combatEffect.setH(self.combatEffect, 180)

        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()
コード例 #55
0
    def checkComboExpired(self, avId, weaponId, skillId, skillResult):
        attacker = base.cr.doId2do.get(avId)
        if not attacker:
            return 0
        if skillId in self.EXCLUDED_SKILLS:
            return 0
        skillInfo = WeaponGlobals.getSkillAnimInfo(skillId)
        if not skillInfo:
            return 0
        barTime = self.TimingCache.get(skillId, None)
        if barTime is None:
            anim = skillInfo[WeaponGlobals.PLAYABLE_INDEX]
            skillAnim = getattr(base.cr.combatAnims,
                                anim)(attacker, skillId, 0, 0, None,
                                      skillResult)
            if skillAnim == None:
                return 1
            barTime = skillAnim.getDuration()
            self.TimingCache[skillId] = barTime
        curTime = globalClock.getFrameTime()
        for attackerId in self.timers:
            comboLength = len(self.timers[attackerId])
            lastEntry = self.timers[attackerId][comboLength - 1]
            lastSkillId = lastEntry[self.SKILLID_INDEX]
            timestamp = lastEntry[self.TIMESTAMP_INDEX]
            if barTime + timestamp - curTime + self.TOLERANCE > 0:
                if attackerId != avId:
                    return 0
                subtypeId = ItemGlobals.getSubtype(weaponId)
                if not subtypeId:
                    return 0
                repId = WeaponGlobals.getSkillReputationCategoryId(skillId)
                if not repId:
                    return 0
                if repId != WeaponGlobals.getRepId(weaponId):
                    return 0
                comboChain = self.COMBO_ORDER.get(subtypeId)
                if comboChain:
                    if skillId in self.SPECIAL_SKILLS.get(repId, []):
                        if lastSkillId not in self.SPECIAL_SKILLS.get(
                                repId, []):
                            return 0
                        elif lastSkillId == skillId:
                            numHits = WeaponGlobals.getNumHits(skillId)
                            if comboLength < numHits:
                                return 0
                            elif comboLength >= numHits:
                                preMultihitEntry = self.timers[attackerId][
                                    comboLength - numHits]
                                preMultihitSkillId = preMultihitEntry[
                                    self.SKILLID_INDEX]
                                if preMultihitSkillId != skillId:
                                    return 0
                    elif skillId in comboChain:
                        index = comboChain.index(skillId)
                        if index > 0:
                            requisiteAttack = comboChain[index - 1]
                            if lastSkillId == requisiteAttack:
                                return 0
                            currentAttack = comboChain[index]
                            if lastSkillId == skillId:
                                return 0
                        elif not comboLength:
                            return 0

        return 1
コード例 #56
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)
コード例 #57
0
 def targetedWeaponHit(self,
                       skillId,
                       ammoSkillId,
                       skillResult,
                       targetEffects,
                       attacker,
                       pos,
                       charge=0,
                       delay=None,
                       multihit=0,
                       itemEffects=[]):
     if self == attacker and not (targetEffects[0] or targetEffects[1] or
                                  targetEffects[2] or targetEffects[3] > 0
                                  or targetEffects[4]):
         if not WeaponGlobals.isSelfUseSkill(skillId):
             return
         if not delay:
             targetPos, time, impactT = self.getProjectileInfo(
                 skillId, attacker)
             if impactT:
                 delay = impactT
             else:
                 delay = WeaponGlobals.getAttackReactionDelay(
                     skillId, ammoSkillId)
         if WeaponGlobals.getIsDollAttackSkill(skillId):
             delay += random.uniform(0.0, 0.5)
         if attacker:
             if attacker.isLocal():
                 self.localAttackedMe()
                 centerEffect = WeaponGlobals.getCenterEffect(
                     skillId, ammoSkillId)
                 if self.hasNetPythonTag('MonstrousObject'):
                     pass
                 elif centerEffect == 2 or not (
                         self.avatarType.isA(AvatarTypes.Stump)
                         or self.avatarType.isA(AvatarTypes.FlyTrap)
                         or self.avatarType.isA(AvatarTypes.GiantCrab)
                         or self.avatarType.isA(AvatarTypes.CrusherCrab)):
                     mult = 0.666
                     if self.avatarType.isA(
                             AvatarTypes.GiantCrab) or self.avatarType.isA(
                                 AvatarTypes.CrusherCrab):
                         mult = 0.1
                     else:
                         if self.avatarType.isA(AvatarTypes.RockCrab):
                             mult = 0.2
                     pos = Vec3(0, 0, self.height * mult)
                 elif centerEffect == 1:
                     newZ = attacker.getZ(self)
                     pos = Vec3(0, 0, newZ + attacker.height * 0.666)
                 else:
                     newPos = self.cr.targetMgr.getAimHitPos(attacker)
                     if newPos:
                         pos = Vec3(newPos[0], newPos[1], newPos[2] + 1.5)
             else:
                 centerEffect = WeaponGlobals.getCenterEffect(
                     skillId, ammoSkillId)
                 if centerEffect >= 1:
                     pos = Vec3(0, 0, self.height * 0.666)
             weaponSubType = None
             if attacker:
                 if attacker.currentWeapon:
                     weaponType = ItemGlobals.getType(
                         attacker.currentWeapon.itemId)
                     if weaponType in [ItemGlobals.SWORD]:
                         weaponSubType = ItemGlobals.getSubtype(
                             attacker.currentWeapon.itemId)
                     elif attacker.currentWeapon.getName() in ['sword']:
                         weaponSubType = ItemGlobals.CUTLASS
                 if delay > 0.0:
                     taskMgr.doMethodLater(
                         delay,
                         self.playHitSound,
                         self.taskName('playHitSoundTask'),
                         extraArgs=[
                             skillId, ammoSkillId, skillResult,
                             weaponSubType
                         ])
                 else:
                     self.playHitSound(skillId, ammoSkillId, skillResult,
                                       weaponSubType)
                 if skillResult in [
                         WeaponGlobals.RESULT_HIT,
                         WeaponGlobals.RESULT_MISTIMED_HIT,
                         WeaponGlobals.RESULT_REFLECTED
                 ]:
                     bonus = 0
                     if bonus:
                         targetEffects[0] -= bonus
                     if skillResult == WeaponGlobals.RESULT_MISTIMED_HIT:
                         if type(targetEffects) is types.TupleType:
                             targetEffects = (int(
                                 targetEffects[0] *
                                 WeaponGlobals.MISTIME_PENALTY),
                                              ) + targetEffects[1:]
                         else:
                             targetEffects[0] = int(
                                 targetEffects[0] *
                                 WeaponGlobals.MISTIME_PENALTY)
                     delay > 0.0 and taskMgr.doMethodLater(
                         delay,
                         self.playOuch,
                         self.taskName('playOuchTask'),
                         extraArgs=[
                             skillId, ammoSkillId, targetEffects, attacker,
                             pos, itemEffects, multihit, 0, skillResult
                         ])
                 else:
                     self.playOuch(skillId,
                                   ammoSkillId,
                                   targetEffects,
                                   attacker,
                                   pos,
                                   itemEffects,
                                   multihit,
                                   skillResult=skillResult)
                 if bonus:
                     taskMgr.doMethodLater(
                         WeaponGlobals.COMBO_DAMAGE_DELAY,
                         self.playOuch,
                         self.taskName('playBonusOuchTask'),
                         extraArgs=[
                             skillId, ammoSkillId, [bonus, 0, 0, 0, 0],
                             attacker, pos, itemEffects, multihit, 1
                         ])
                 skillId in WeaponGlobals.BackstabSkills and charge and attacker and attacker.isLocal(
                 ) and ItemGlobals.getSubtype(
                     attacker.currentWeaponId
                 ) == ItemGlobals.DAGGER_SUBTYPE and messenger.send(
                     ('').join(['trackBackstab-',
                                str(self.doId)]))
     else:
         if skillResult == WeaponGlobals.RESULT_MISS or skillResult == WeaponGlobals.RESULT_MISTIMED_MISS or skillResult == WeaponGlobals.RESULT_DODGE or skillResult == WeaponGlobals.RESULT_PARRY or skillResult == WeaponGlobals.RESULT_RESIST or skillResult == WeaponGlobals.RESULT_PROTECT:
             resultString = WeaponGlobals.getSkillResultName(skillResult)
             delay = WeaponGlobals.getAttackReactionDelay(
                 skillId, ammoSkillId)
             if delay > 0.0:
                 taskMgr.doMethodLater(delay,
                                       self.showHpString,
                                       self.taskName('showMissTask'),
                                       extraArgs=[resultString, pos])
             else:
                 self.showHpString(resultString, pos)
         else:
             if skillResult == WeaponGlobals.RESULT_OUT_OF_RANGE or skillResult == WeaponGlobals.RESULT_BLOCKED:
                 pass
             else:
                 if skillResult == WeaponGlobals.RESULT_AGAINST_PIRATE_CODE:
                     if attacker:
                         resultString = attacker.isLocal(
                         ) and WeaponGlobals.getSkillResultName(skillResult)
                         self.showHpString(resultString, pos)
                 else:
                     if skillResult == WeaponGlobals.RESULT_NOT_AVAILABLE:
                         self.notify.warning(
                             'WeaponGlobals.RESULT_NOT_AVAILABLE')
                     else:
                         self.notify.error('unknown skillResult: %d' %
                                           skillResult)
     return
コード例 #58
0
    def loadWeaponButtons(self):
        for hotkey in self.hotkeys:
            hotkey.destroy()

        self.hotkeys = []
        for icon in self.icons:
            icon.destroy()

        self.icons = []
        for repMeter in self.repMeters:
            repMeter.destroy()

        self.repMeters = []
        self['frameSize'] = (0, self.ICON_WIDTH * len(self.items) +
                             0.040000000000000001, 0, self.HEIGHT)
        self.setX(-(
            (self.ICON_WIDTH * len(self.items) + 0.040000000000000001) / 2.0))
        topGui = loader.loadModel('models/gui/toplevel_gui')
        kbButton = topGui.find('**/keyboard_button')
        for i in range(len(self.items)):
            if self.items[i]:
                category = WeaponGlobals.getRepId(self.items[i][0])
                icon = DirectFrame(
                    parent=self,
                    state=DGG.DISABLED,
                    relief=None,
                    frameSize=(0, 0.080000000000000002, 0,
                               0.080000000000000002),
                    pos=(self.ICON_WIDTH * i + 0.080000000000000002, 0,
                         0.082000000000000003))
                icon.setTransparency(1)
                hotkeyText = 'F%s' % self.items[i][1]
                hotkey = DirectFrame(parent=icon,
                                     state=DGG.DISABLED,
                                     relief=None,
                                     text=hotkeyText,
                                     text_align=TextNode.ACenter,
                                     text_scale=0.044999999999999998,
                                     text_pos=(0, 0),
                                     text_fg=PiratesGuiGlobals.TextFG2,
                                     text_shadow=PiratesGuiGlobals.TextShadow,
                                     image=kbButton,
                                     image_scale=0.059999999999999998,
                                     image_pos=(0, 0, 0.01),
                                     image_color=(0.5, 0.5,
                                                  0.34999999999999998, 1),
                                     pos=(0, 0, 0.080000000000000002))
                self.hotkeys.append(hotkey)
                category = WeaponGlobals.getRepId(self.items[i][0])
                if Freebooter.getPaidStatus(base.localAvatar.getDoId(
                )) or Freebooter.allowedFreebooterWeapon(category):
                    asset = ItemGlobals.getIcon(self.items[i][0])
                    if asset:
                        texCard = self.card.find('**/%s' % asset)
                        icon['geom'] = texCard
                        icon['geom_scale'] = 0.080000000000000002

                    icon.resetFrameSize()
                    self.icons.append(icon)
                else:
                    texCard = topGui.find('**/pir_t_gui_gen_key_subscriber*')
                    icon['geom'] = texCard
                    icon['geom_scale'] = 0.20000000000000001
                    icon.resetFrameSize()
                    self.icons.append(icon)
                repMeter = DirectWaitBar(
                    parent=icon,
                    relief=DGG.SUNKEN,
                    state=DGG.DISABLED,
                    borderWidth=(0.002, 0.002),
                    range=0,
                    value=0,
                    frameColor=(0.23999999999999999, 0.23999999999999999,
                                0.20999999999999999, 1),
                    barColor=(0.80000000000000004, 0.80000000000000004,
                              0.69999999999999996, 1),
                    pos=(-0.050000000000000003, 0, -0.052499999999999998),
                    hpr=(0, 0, 0),
                    frameSize=(0.0050000000000000001, 0.095000000000000001, 0,
                               0.012500000000000001))
                self.repMeters.append(repMeter)
                inv = base.localAvatar.getInventory()
                if inv:
                    repValue = inv.getReputation(category)
                    (level, leftoverValue
                     ) = ReputationGlobals.getLevelFromTotalReputation(
                         category, repValue)
                    max = ReputationGlobals.getReputationNeededToLevel(
                        category, level)
                    repMeter['range'] = max
                    repMeter['value'] = leftoverValue
コード例 #59
0
    def setupItems(self, itemList):
        for itemId in itemList:
            itemClass = ItemGlobals.getClass(itemId)
            itemType = EconomyGlobals.getItemType(itemId)
            itemTuple = [itemClass, itemId, 0, 0]
            item = None
            if itemClass == InventoryType.ItemTypeWeapon:
                item = self.manager.makeWeaponItem(itemTuple)
            else:
                if itemClass == InventoryType.ItemTypeCharm:
                    item = self.manager.makeCharmItem(itemTuple)
                elif itemClass == InventoryType.ItemTypeConsumable:
                    itemTuple[3] = 1
                    item = self.manager.makeConsumableItem(itemTuple,
                                                           showMax=0)
                elif itemClass == InventoryType.ItemTypeClothing:
                    item = self.manager.makeClothingItem(itemTuple)
                else:
                    if itemClass == InventoryType.ItemTypeMoney:
                        item = self.manager.makeGoldItem(itemTuple)
                    elif itemClass == InventoryType.TreasureCollection:
                        item = self.manager.makeTreasureItem(itemTuple)
                    elif itemClass == InventoryType.ItemTypeJewelry:
                        item = self.manager.makeJewelryItem(itemTuple)
                    elif itemClass == InventoryType.ItemTypeTattoo:
                        item = self.manager.makeTattooItem(itemTuple)
                    elif itemClass == InventoryCategory.CARDS:
                        cardId = itemId
                        itemTuple[1] -= InventoryType.begin_Cards
                        item = self.manager.makeCardItem(cardId,
                                                         itemTuple,
                                                         imageScaleFactor=1.9)
                    elif itemClass == InventoryCategory.WEAPON_PISTOL_AMMO:
                        itemTuple[1] = WeaponGlobals.getSkillAmmoInventoryId(
                            itemId)
                        item = self.manager.makeAmmoItem(itemId,
                                                         itemTuple,
                                                         showMax=0)
                    elif itemType in [
                            EconomyGlobals.ItemType.DAGGERAMMO,
                            EconomyGlobals.ItemType.PISTOLAMMO,
                            EconomyGlobals.ItemType.GRENADEAMMO,
                            EconomyGlobals.ItemType.CANNONAMMO
                    ]:
                        itemTuple = [
                            0, itemId, 0,
                            EconomyGlobals.getItemQuantity(itemId)
                        ]
                        skillId = WeaponGlobals.getSkillIdForAmmoSkillId(
                            itemId)
                        item = self.manager.makeAmmoItem(skillId,
                                                         itemTuple,
                                                         showMax=0)
                    elif itemType in [
                            EconomyGlobals.ItemType.PISTOL_POUCH,
                            EconomyGlobals.ItemType.DAGGER_POUCH,
                            EconomyGlobals.ItemType.GRENADE_POUCH,
                            EconomyGlobals.ItemType.CANNON_POUCH,
                            EconomyGlobals.ItemType.FISHING_POUCH
                    ]:
                        item = self.manager.makePouchItem(itemTuple)
                    elif itemType in (EconomyGlobals.ItemType.FISHING_LURE, ):
                        itemTuple[1] = WeaponGlobals.getSkillAmmoInventoryId(
                            itemId)
                        itemTuple[3] = EconomyGlobals.getItemQuantity(itemId)
                        item = self.manager.makeFishingItem(itemId,
                                                            itemTuple,
                                                            showMax=0)
                    if itemClass in (InventoryType.ItemTypeMoney,
                                     InventoryCategory.CARDS,
                                     InventoryType.TreasureCollection):
                        self.addGridCell(self.stackImage, 1.0)
                    if itemClass == InventoryCategory.WEAPON_PISTOL_AMMO:
                        self.addGridCell(self.stackImage2, 1.0)
                    if itemType in (EconomyGlobals.ItemType.FISHING_LURE, ):
                        self.addGridCell(self.stackImage, 1.0)
                    self.addGridCell()
                if item:
                    self.tryPutIntoFirstOpenCell(item)
            item.showResaleValue = False
            if self.zCount == self.gridZ:
                break

        while self.zCount < self.gridZ:
            self.addGridCell()

        return
コード例 #60
0
def pruneFreebooterSkills(skillTrack):
    if getPaidStatus(base.localAvatar.getDoId()):
        return skillTrack
    else:
        return filter(lambda skillId: WeaponGlobals.canFreeUse(skillId),
                      skillTrack)