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
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
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)
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)
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
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
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
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 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 figureOutStackTypes(self): repCategoryDict = {} for itemId in self.itemList: skillRepId = WeaponGlobals.getSkillReputationCategoryId(itemId) if self.isSkillValid(itemId): if not repCategoryDict.has_key(skillRepId): repCategoryDict[skillRepId] = [] repCategoryDict[skillRepId].append(itemId) self.listOfItemLists = [] for key in repCategoryDict: itemList = repCategoryDict[key] while len(itemList) > self.maxCountX: frontList = itemList[:self.maxCountX] backList = itemList[self.maxCountX:] self.listOfItemLists.append(frontList) itemList = backList self.listOfItemLists.append(itemList)
def figureOutStackTypes(self): repCategoryDict = {} for itemId in self.itemList: skillRepId = WeaponGlobals.getSkillReputationCategoryId(itemId) if self.isSkillValid(itemId): if not repCategoryDict.has_key(skillRepId): repCategoryDict[skillRepId] = [] repCategoryDict[skillRepId].append(itemId) continue self.listOfItemLists = [] for key in repCategoryDict: itemList = repCategoryDict[key] while len(itemList) > self.maxCountX: frontList = itemList[: self.maxCountX] backList = itemList[self.maxCountX :] self.listOfItemLists.append(frontList) itemList = backList self.listOfItemLists.append(itemList)
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
def updateSkillTray(self, rep, weaponMode, callback = None, hideFirst = True): if rep == InventoryType.MeleeRep: return None if not callback: callback = localAvatar.guiMgr.combatTray.triggerSkillTraySkill if taskMgr.hasTaskNamed('updateSkillTray'): taskMgr.remove('updateSkillTray') if self.skillTrayState and hideFirst: self.hideSkillTray() taskMgr.doMethodLater(0.75, self.updateSkillTray, 'updateSkillTray', extraArgs = [ rep, weaponMode, callback]) return None text = PLocalizer.InventoryTypeNames.get(rep, 'Unknown') for i in range(self.numberOfItems): self.tray[i + 1].destroy() self.tray = { } if self.repMeter: self.repMeter.destroy() self.rep = rep self.weaponMode = weaponMode self.callback = callback linkedSkillIds = { } linkedSkills = ItemGlobals.getLinkedSkills(localAvatar.currentWeaponId) for skillId in linkedSkills: realSkillId = WeaponGlobals.getLinkedSkillId(skillId) linkedSkillIds[realSkillId] = skillId skillMap = [] self.origMap = getAllSkills(self.rep, 2, wantWeaponSkill = 1) for i in range(len(self.origMap)): skillMap.append(self.origMap[i][0]) self.traySkillMap = skillMap self.numberOfItems = len(self.traySkillMap) self.skillTray.setX(0) if self.rep != InventoryType.DefenseCannonRep: self.repMeter = ReputationMeter(self.rep, width = 0.69999999999999996) self.repMeter.setScale(1.1499999999999999, 1.1499999999999999, 1.1499999999999999) self.repMeter.reparentTo(self.skillTray) self.repMeter.setCategory(self.rep) inv = base.localAvatar.getInventory() if inv is None: return None if self.repMeter: self.repMeter.update(inv.getReputation(self.rep)) x = 0.0 offset = 0.0 for i in range(self.numberOfItems): if self.origMap[i][1] == False: locked = False if locked: image = (self.SkillIcons.find('**/base'), self.SkillIcons.find('**/base_down'), self.SkillIcons.find('**/base_over')) else: image = self.SkillIcons.find('**/base') button = DirectButton(parent = self.skillTray, relief = None, state = DGG.DISABLED, image = image, image_pos = (0.0, 0.0, 0.059999999999999998), image_scale = 0.12, image_color = (0.20000000000000001, 0.20000000000000001, 0.20000000000000001, 0.55000000000000004), sortOrder = 100, pos = (x, 0, -0.0)) button.setTransparency(1) button.showQuantity = False button.greyOut = -1 button.showRing = False button.skillStatus = False if locked: lock = DirectFrame(parent = button, relief = None, image = self.lockArt, image_scale = 0.14000000000000001, image_pos = (0.050000000000000003, 0, 0.035000000000000003)) button['state'] = DGG.NORMAL button['command'] = base.localAvatar.guiMgr.showNonPayer button['extraArgs'] = [ 'Restricted_Radial_Menu', 5] self.tray[i + 1] = button x = x + 0.14999999999999999 if i < self.numberOfItems - 1: offset = offset + 0.01 self.skillTray.setX(self.skillTray.getX() - 0.074999999999999997) i < self.numberOfItems - 1 if self.origMap[i][1] == True: skillId = self.traySkillMap[i] if linkedSkillIds.has_key(skillId): skillId = linkedSkillIds[skillId] name = PLocalizer.InventoryTypeNames[skillId] hotkey = str(i + 1) totalRechargeTime = base.cr.battleMgr.getModifiedRechargeTime(localAvatar, skillId) timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging(skillId) if not timeSpentRecharging: timeSpentRecharging = 0 if weaponMode not in (WeaponGlobals.CANNON, WeaponGlobals.FIREARM, WeaponGlobals.GRENADE, WeaponGlobals.STAFF, WeaponGlobals.DEFENSE_CANNON) and skillId in WeaponGlobals.SpecialSkills or WeaponGlobals.getSkillReputationCategoryId(skillId) not in (InventoryType.PistolRep, InventoryType.WandRep, InventoryType.CannonRep, InventoryType.GrenadeRep, InventoryType.DefenseCannonRep): showRing = True else: showRing = False locked = self.origMap[i][2] if weaponMode == WeaponGlobals.DEFENSE_CANNON: button = AmmoSkillButton(skillId, i, self.callback, 99, 0, showQuantity = True, showHelp = False, showRing = showRing, hotkey = hotkey, name = name, showLock = locked) else: button = SkillButton(skillId, self.callback, 0, 0, showQuantity = False, showHelp = False, showRing = showRing, hotkey = hotkey, name = name, showLock = locked) button.skillStatus = True if locked: button.skillButton['command'] = base.localAvatar.guiMgr.showNonPayer button.skillButton['extraArgs'] = [ 'Restricted_Radial_Menu', 5] if showRing: button.skillRing.meterFaceHalf1.setScale(0.95999999999999996) button.skillRing.meterFaceHalf2.setScale(0.95999999999999996) button.reparentTo(self.skillTray) button.setPos(x, 0, 0.070000000000000007) self.tray[i + 1] = button if weaponMode in (WeaponGlobals.CANNON, WeaponGlobals.FIREARM, WeaponGlobals.GRENADE, WeaponGlobals.STAFF): lastAmmo = localAvatar.guiMgr.combatTray.lastAmmoSkillId.get(localAvatar.currentWeaponId) if lastAmmo is not None: if lastAmmo == skillId: button.toggleButton(True) elif self.tray[1].skillStatus is True: self.tray[1].toggleButton(True) if self.weaponMode in (WeaponGlobals.FIREARM, WeaponGlobals.THROWING, WeaponGlobals.CANNON, WeaponGlobals.GRENADE): inv = localAvatar.getInventory() 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) button.showQuantity = True button.updateQuantity(ammoAmt) x = x + 0.17000000000000001 if i < self.numberOfItems - 1: if weaponMode == WeaponGlobals.DEFENSE_CANNON: self.skillTray.setX(self.skillTray.getX() - 0.072499999999999995) else: self.skillTray.setX(self.skillTray.getX() - 0.085000000000000006) i < self.numberOfItems - 1 currentX = self.skillTray.getX() self.skillTray.setX(currentX + float(offset)) if self.repMeter: self.repMeter.setPos(-currentX, 0.0, -0.11) self.updateSkillTrayStates() if weaponMode == WeaponGlobals.DEFENSE_CANNON: self.setMoveUpValue(0.34499999999999997) else: self.resetMoveUpVale() self.showSkillTray()
def updateSkillTrayStates(self): if not self.traySkillMap: 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): skillId = self.traySkillMap[i] greyOut = 0 if self.tray[i + 1].greyOut == -1: continue if self.tray[i + 1].showQuantity: maxQuant = WeaponGlobals.getSkillMaxQuantity(skillId) if maxQuant == WeaponGlobals.INF_QUANT and WeaponGlobals.canUseInfiniteAmmo(localAvatar.currentWeaponId, skillId) or WeaponGlobals.canUseInfiniteAmmo(localAvatar.getCurrentCharm(), skillId): quantity = WeaponGlobals.INF_QUANT else: ammoInvId = WeaponGlobals.getSkillAmmoInventoryId(skillId) quantity = inv.getStackQuantity(ammoInvId) if quantity == 0: greyOut = 1 if localAvatar.mojo < -1 * WeaponGlobals.getMojoCost(skillId): greyOut = 1 if localAvatar.ship: if (skillId == InventoryType.SailBroadsideLeft or skillId == InventoryType.SailBroadsideRight) and not (localAvatar.ship.broadside): greyOut = 1 elif localAvatar.guiMgr.combatTray.skillDisabled(skillId): greyOut = 1 rep = WeaponGlobals.getSkillReputationCategoryId(skillId) if rep == InventoryType.DollRep: haveFriendly = localAvatar.getFriendlyStickyTargets() haveHostile = localAvatar.getHostileStickyTargets() if haveFriendly and not haveHostile: if not WeaponGlobals.isFriendlyFire(skillId): greyOut = 1 elif not haveFriendly and haveHostile: if WeaponGlobals.isFriendlyFire(skillId): greyOut = 1 if self.tray[i + 1].greyOut != greyOut: if hasattr(self.tray[i + 1], 'skillButton'): self.tray[i + 1].greyOut = greyOut if greyOut == 1: self.tray[i + 1].setGeomColor(0.5, 0.5, 0.5, 1.0) if self.tray[i + 1].showRing: self.tray[i + 1].skillRing.meterFaceHalf1.setColorScale(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1.0) self.tray[i + 1].skillRing.meterFaceHalf2.setColorScale(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1.0) elif greyOut == 2: self.tray[i + 1].setGeomColor(0.5, 0.5, 0.5, 1.0) elif greyOut == 3: self.tray[i + 1].setGeomColor(0.5, 0.5, 0.5, 1.0) else: self.tray[i + 1].setGeomColor(1, 1, 1, 1) if self.tray[i + 1].showRing: self.tray[i + 1].skillRing.meterFaceHalf1.clearColorScale() self.tray[i + 1].skillRing.meterFaceHalf2.clearColorScale() if self.isPowerRecharged: self.continuePowerRechargeEffect() continue
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
def updateSkillTray(self, rep, weaponMode, callback = None, hideFirst = True): if rep == InventoryType.MeleeRep: return None if not callback: callback = localAvatar.guiMgr.combatTray.triggerSkillTraySkill if taskMgr.hasTaskNamed('updateSkillTray'): taskMgr.remove('updateSkillTray') if self.skillTrayState and hideFirst: self.hideSkillTray() taskMgr.doMethodLater(0.75, self.updateSkillTray, 'updateSkillTray', extraArgs = [ rep, weaponMode, callback]) return None text = PLocalizer.InventoryTypeNames.get(rep, 'Unknown') for i in range(self.numberOfItems): self.tray[i + 1].destroy() self.tray = { } if self.repMeter: self.repMeter.destroy() self.rep = rep self.weaponMode = weaponMode self.callback = callback linkedSkillIds = { } linkedSkills = ItemGlobals.getLinkedSkills(localAvatar.currentWeaponId) for skillId in linkedSkills: realSkillId = WeaponGlobals.getLinkedSkillId(skillId) linkedSkillIds[realSkillId] = skillId skillMap = [] self.origMap = getAllSkills(self.rep, 2, wantWeaponSkill = 1) for i in range(len(self.origMap)): skillMap.append(self.origMap[i][0]) self.traySkillMap = skillMap self.numberOfItems = len(self.traySkillMap) self.skillTray.setX(0) if self.rep != InventoryType.DefenseCannonRep: self.repMeter = ReputationMeter(self.rep, width = 0.69999999999999996) self.repMeter.setScale(1.1499999999999999, 1.1499999999999999, 1.1499999999999999) self.repMeter.reparentTo(self.skillTray) self.repMeter.setCategory(self.rep) inv = base.localAvatar.getInventory() if inv is None: return None if self.repMeter: self.repMeter.update(inv.getReputation(self.rep)) x = 0.0 offset = 0.0 for i in range(self.numberOfItems): if self.origMap[i][1] == False: locked = False if locked: image = (self.SkillIcons.find('**/base'), self.SkillIcons.find('**/base_down'), self.SkillIcons.find('**/base_over')) else: image = self.SkillIcons.find('**/base') button = DirectButton(parent = self.skillTray, relief = None, state = DGG.DISABLED, image = image, image_pos = (0.0, 0.0, 0.059999999999999998), image_scale = 0.12, image_color = (0.20000000000000001, 0.20000000000000001, 0.20000000000000001, 0.55000000000000004), sortOrder = 100, pos = (x, 0, -0.0)) button.setTransparency(1) button.showQuantity = False button.greyOut = -1 button.showRing = False button.skillStatus = False if locked: lock = DirectFrame(parent = button, relief = None, image = self.lockArt, image_scale = 0.14000000000000001, image_pos = (0.050000000000000003, 0, 0.035000000000000003)) button['state'] = DGG.NORMAL button['command'] = base.localAvatar.guiMgr.showNonPayer button['extraArgs'] = [ 'Restricted_Radial_Menu', 5] self.tray[i + 1] = button x = x + 0.14999999999999999 if i < self.numberOfItems - 1: offset = offset + 0.01 self.skillTray.setX(self.skillTray.getX() - 0.074999999999999997) i < self.numberOfItems - 1 if self.origMap[i][1] == True: skillId = self.traySkillMap[i] if linkedSkillIds.has_key(skillId): skillId = linkedSkillIds[skillId] name = PLocalizer.InventoryTypeNames[skillId] hotkey = str(i + 1) totalRechargeTime = base.cr.battleMgr.getModifiedRechargeTime(localAvatar, skillId) timeSpentRecharging = localAvatar.skillDiary.getTimeSpentRecharging(skillId) if not timeSpentRecharging: timeSpentRecharging = 0 if weaponMode not in (WeaponGlobals.CANNON, WeaponGlobals.FIREARM, WeaponGlobals.GRENADE, WeaponGlobals.STAFF, WeaponGlobals.DEFENSE_CANNON) and skillId in WeaponGlobals.SpecialSkills or WeaponGlobals.getSkillReputationCategoryId(skillId) not in (InventoryType.PistolRep, InventoryType.WandRep, InventoryType.CannonRep, InventoryType.GrenadeRep, InventoryType.DefenseCannonRep): showRing = True else: showRing = False locked = self.origMap[i][2] if weaponMode == WeaponGlobals.DEFENSE_CANNON: button = AmmoSkillButton(skillId, i, self.callback, 99, 0, showQuantity = True, showHelp = False, showRing = showRing, hotkey = hotkey, name = name, showLock = locked) else: button = SkillButton(skillId, self.callback, 0, 0, showQuantity = False, showHelp = False, showRing = showRing, hotkey = hotkey, name = name, showLock = locked) button.skillStatus = True if locked: button.skillButton['command'] = base.localAvatar.guiMgr.showNonPayer button.skillButton['extraArgs'] = [ 'Restricted_Radial_Menu', 5] if showRing: button.skillRing.meterFaceHalf1.setScale(0.95999999999999996) button.skillRing.meterFaceHalf2.setScale(0.95999999999999996) button.reparentTo(self.skillTray) button.setPos(x, 0, 0.070000000000000007) self.tray[i + 1] = button if weaponMode in (WeaponGlobals.CANNON, WeaponGlobals.FIREARM, WeaponGlobals.GRENADE, WeaponGlobals.STAFF): lastAmmo = localAvatar.guiMgr.combatTray.lastAmmoSkillId.get(localAvatar.currentWeaponId) if lastAmmo is not None: if lastAmmo == skillId: button.toggleButton(True) elif self.tray[1].skillStatus is True: self.tray[1].toggleButton(True) if self.weaponMode in (WeaponGlobals.FIREARM, WeaponGlobals.THROWING, WeaponGlobals.CANNON, WeaponGlobals.GRENADE): inv = localAvatar.getInventory() 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) button.showQuantity = True button.updateQuantity(ammoAmt) x = x + 0.17000000000000001 if i < self.numberOfItems - 1: if weaponMode == WeaponGlobals.DEFENSE_CANNON: self.skillTray.setX(self.skillTray.getX() - 0.072499999999999995) else: self.skillTray.setX(self.skillTray.getX() - 0.085000000000000006) i < self.numberOfItems - 1 currentX = self.skillTray.getX() self.skillTray.setX(currentX + float(offset)) if self.repMeter: self.repMeter.setPos(-currentX, 0.0, -0.11) self.updateSkillTrayStates() if weaponMode == WeaponGlobals.DEFENSE_CANNON: self.setMoveUpValue(0.34499999999999997) else: self.resetMoveUpVale() self.showSkillTray()
def updateSkillTrayStates(self): if not self.traySkillMap: 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): skillId = self.traySkillMap[i] greyOut = 0 if self.tray[i + 1].greyOut == -1: continue if self.tray[i + 1].showQuantity: maxQuant = WeaponGlobals.getSkillMaxQuantity(skillId) if maxQuant == WeaponGlobals.INF_QUANT and WeaponGlobals.canUseInfiniteAmmo(localAvatar.currentWeaponId, skillId) or WeaponGlobals.canUseInfiniteAmmo(localAvatar.getCurrentCharm(), skillId): quantity = WeaponGlobals.INF_QUANT else: ammoInvId = WeaponGlobals.getSkillAmmoInventoryId(skillId) quantity = inv.getStackQuantity(ammoInvId) if quantity == 0: greyOut = 1 if localAvatar.mojo < -1 * WeaponGlobals.getMojoCost(skillId): greyOut = 1 if localAvatar.ship: if (skillId == InventoryType.SailBroadsideLeft or skillId == InventoryType.SailBroadsideRight) and not (localAvatar.ship.broadside): greyOut = 1 elif localAvatar.guiMgr.combatTray.skillDisabled(skillId): greyOut = 1 rep = WeaponGlobals.getSkillReputationCategoryId(skillId) if rep == InventoryType.DollRep: haveFriendly = localAvatar.getFriendlyStickyTargets() haveHostile = localAvatar.getHostileStickyTargets() if haveFriendly and not haveHostile: if not WeaponGlobals.isFriendlyFire(skillId): greyOut = 1 elif not haveFriendly and haveHostile: if WeaponGlobals.isFriendlyFire(skillId): greyOut = 1 if self.tray[i + 1].greyOut != greyOut: if hasattr(self.tray[i + 1], 'skillButton'): self.tray[i + 1].greyOut = greyOut if greyOut == 1: self.tray[i + 1].setGeomColor(0.5, 0.5, 0.5, 1.0) if self.tray[i + 1].showRing: self.tray[i + 1].skillRing.meterFaceHalf1.setColorScale(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1.0) self.tray[i + 1].skillRing.meterFaceHalf2.setColorScale(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1.0) elif greyOut == 2: self.tray[i + 1].setGeomColor(0.5, 0.5, 0.5, 1.0) elif greyOut == 3: self.tray[i + 1].setGeomColor(0.5, 0.5, 0.5, 1.0) else: self.tray[i + 1].setGeomColor(1, 1, 1, 1) if self.tray[i + 1].showRing: self.tray[i + 1].skillRing.meterFaceHalf1.clearColorScale() self.tray[i + 1].skillRing.meterFaceHalf2.clearColorScale() if self.isPowerRecharged: self.continuePowerRechargeEffect() continue