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)
Exemplo n.º 2
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)
Exemplo n.º 3
0
 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:
                 return (not TeamUtils.damageAllowed(localAvatar, target) and not WeaponGlobals.isFriendlyFire(skillId, ammoSkillId) and 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) and not (ItemGlobals.getSubtype(localAvatar.currentWeaponId) == ItemGlobals.BAYONET and 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 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 radialMenuHeartBeat(self, task):
     if base.mouseWatcherNode.hasMouse():
         mouseData = base.win.getPointer(0)
         curX = mouseData.getX()
         curY = mouseData.getY()
     else:
         curX = 0
         curY = 0
     hLItem = RingMatch(self.numberOfItems, curX - self.mouseBasePosX, curY - self.mouseBasePosY)
     if hLItem != self.hiLiteItem:
         if hLItem < 1:
             self.radialHelp.hide()
         else:
             self.radialHelp['text'] = PLocalizer.InventoryTypeNames[self.radialSkillMap[hLItem - 1]]
             basePos = self.radial[hLItem].getPos()
             self.radialHelp.setPos(basePos[0] + 0.059999999999999998, basePos[1], basePos[2] - 0.040000000000000001)
             self.radialHelp.show()
         if self.hiLiteItem != -1:
             self.rframe[self.hiLiteItem].rollover(False)
         
         self.hiLiteItem = hLItem
         if self.hiLiteItem > 0:
             self.rframe[self.hiLiteItem].rollover(True)
         
     
     count = 0
     for skillId in self.radialSkillMap:
         greyOut = 0
         count += 1
         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):
                 greyOut = 0
             else:
                 ammoInvId = WeaponGlobals.getSkillAmmoInventoryId(skillId)
                 ammoAmt = inv.getStackQuantity(ammoInvId)
                 if ammoAmt <= 0:
                     greyOut = 1
                 
         
         if localAvatar.mojo < -1 * WeaponGlobals.getMojoCost(skillId):
             greyOut = 1
         
         if skillId == InventoryType.SailBroadsideLeft or skillId == InventoryType.SailBroadsideRight:
             if not localAvatar.ship.broadside:
                 greyOut = 1
             
         
         range = localAvatar.cr.battleMgr.getModifiedRechargeTime(localAvatar, skillId)
         value = localAvatar.skillDiary.getTimeSpentRecharging(skillId)
         if not value:
             value = range
         elif value >= range:
             if self.rstatus[count] == 3:
                 startScale = self.rframe[count].getScale()
                 startColor = Vec4(1, 1, 1, 1)
                 glowColor = Vec4(0.0, 0.75, 0.0, 1.0)
                 buttomFrame = self.rframe[count]
             
         
         self.rframe[count].update(value, range)
         if value < range:
             greyOut = 3
         
         if self.rep == InventoryType.DollRep:
             haveFriendly = localAvatar.getFriendlyStickyTargets()
             haveHostile = localAvatar.getHostileStickyTargets()
             if haveFriendly and not haveHostile:
                 if not WeaponGlobals.isFriendlyFire(self.radialSkillMap[count - 1]):
                     greyOut = 1
                 
             elif not haveFriendly and haveHostile:
                 if WeaponGlobals.isFriendlyFire(self.radialSkillMap[count - 1]):
                     greyOut = 1
                 
             
         
         if self.rstatus[count] != greyOut:
             self.rstatus[count] = greyOut
             if greyOut == 2:
                 self.radial[count].setColorScale(0.69999999999999996, 0.69999999999999996, 0.69999999999999996, 1.0)
             elif greyOut == 1:
                 self.radial[count].setColorScale(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1.0)
                 self.rframe[count].meterFaceHalf1.setColorScale(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1.0)
                 self.rframe[count].meterFaceHalf2.setColorScale(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1.0)
             elif greyOut == 3:
                 self.radial[count].setColorScale(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1.0)
             else:
                 self.radial[count].setColorScale(1, 1, 1, 1)
                 self.radial[count].setAlphaScale(1)
                 self.rframe[count].meterFaceHalf1.setColorScale(1, 1, 1, 1.0)
                 self.rframe[count].meterFaceHalf2.setColorScale(1, 1, 1, 1.0)
         greyOut == 2
     
     return Task.cont
Exemplo n.º 6
0
 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
Exemplo n.º 7
0
 def radialMenuHeartBeat(self, task):
     if base.mouseWatcherNode.hasMouse():
         mouseData = base.win.getPointer(0)
         curX = mouseData.getX()
         curY = mouseData.getY()
     else:
         curX = 0
         curY = 0
     hLItem = RingMatch(self.numberOfItems, curX - self.mouseBasePosX, curY - self.mouseBasePosY)
     if hLItem != self.hiLiteItem:
         if hLItem < 1:
             self.radialHelp.hide()
         else:
             self.radialHelp['text'] = PLocalizer.InventoryTypeNames[self.radialSkillMap[hLItem - 1]]
             basePos = self.radial[hLItem].getPos()
             self.radialHelp.setPos(basePos[0] + 0.059999999999999998, basePos[1], basePos[2] - 0.040000000000000001)
             self.radialHelp.show()
         if self.hiLiteItem != -1:
             self.rframe[self.hiLiteItem].rollover(False)
         
         self.hiLiteItem = hLItem
         if self.hiLiteItem > 0:
             self.rframe[self.hiLiteItem].rollover(True)
         
     
     count = 0
     for skillId in self.radialSkillMap:
         greyOut = 0
         count += 1
         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):
                 greyOut = 0
             else:
                 ammoInvId = WeaponGlobals.getSkillAmmoInventoryId(skillId)
                 ammoAmt = inv.getStackQuantity(ammoInvId)
                 if ammoAmt <= 0:
                     greyOut = 1
                 
         
         if localAvatar.mojo < -1 * WeaponGlobals.getMojoCost(skillId):
             greyOut = 1
         
         if skillId == InventoryType.SailBroadsideLeft or skillId == InventoryType.SailBroadsideRight:
             if not localAvatar.ship.broadside:
                 greyOut = 1
             
         
         range = localAvatar.cr.battleMgr.getModifiedRechargeTime(localAvatar, skillId)
         value = localAvatar.skillDiary.getTimeSpentRecharging(skillId)
         if not value:
             value = range
         elif value >= range:
             if self.rstatus[count] == 3:
                 startScale = self.rframe[count].getScale()
                 startColor = Vec4(1, 1, 1, 1)
                 glowColor = Vec4(0.0, 0.75, 0.0, 1.0)
                 buttomFrame = self.rframe[count]
             
         
         self.rframe[count].update(value, range)
         if value < range:
             greyOut = 3
         
         if self.rep == InventoryType.DollRep:
             haveFriendly = localAvatar.getFriendlyStickyTargets()
             haveHostile = localAvatar.getHostileStickyTargets()
             if haveFriendly and not haveHostile:
                 if not WeaponGlobals.isFriendlyFire(self.radialSkillMap[count - 1]):
                     greyOut = 1
                 
             elif not haveFriendly and haveHostile:
                 if WeaponGlobals.isFriendlyFire(self.radialSkillMap[count - 1]):
                     greyOut = 1
                 
             
         
         if self.rstatus[count] != greyOut:
             self.rstatus[count] = greyOut
             if greyOut == 2:
                 self.radial[count].setColorScale(0.69999999999999996, 0.69999999999999996, 0.69999999999999996, 1.0)
             elif greyOut == 1:
                 self.radial[count].setColorScale(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1.0)
                 self.rframe[count].meterFaceHalf1.setColorScale(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1.0)
                 self.rframe[count].meterFaceHalf2.setColorScale(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1.0)
             elif greyOut == 3:
                 self.radial[count].setColorScale(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1.0)
             else:
                 self.radial[count].setColorScale(1, 1, 1, 1)
                 self.radial[count].setAlphaScale(1)
                 self.rframe[count].meterFaceHalf1.setColorScale(1, 1, 1, 1.0)
                 self.rframe[count].meterFaceHalf2.setColorScale(1, 1, 1, 1.0)
         greyOut == 2
     
     return Task.cont
Exemplo n.º 8
0
 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