本文整理汇总了Python中pirates.battle.WeaponGlobals类的典型用法代码示例。如果您正苦于以下问题:Python WeaponGlobals类的具体用法?Python WeaponGlobals怎么用?Python WeaponGlobals使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WeaponGlobals类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: updateSkillTrayAmounts
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)
示例2: updateIcons
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: _DistributedShipBroadside__requestAttack
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)
示例4: getProjectileInfo
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)
示例5: continuePowerRechargeEffect
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
示例6: updateCharmSkills
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: __init__
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)
示例8: removePowerRechargeEffect
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
示例9: createGui
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: updateSkillId
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)
示例11: getGeomParams
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
示例12: doAttack
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
示例13: takeAim
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)
示例14: isSkillValid
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: cellRightClick
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)