def finishReload(self): newVolley = WeaponGlobals.getAttackVolley(self.skillId, self.getAmmoSkillId()) if newVolley > self.numShots and not WeaponGlobals.isInfiniteAmmo(self.getAmmoSkillId()) and not WeaponGlobals.canUseInfiniteAmmo(localAvatar.getCurrentCharm(), self.getAmmoSkillId()): newVolley = self.numShots self.setVolley(newVolley) self.showCannonDressing()
def changeAmmo(self, amt=1): if amt == 0: return keepChanging = True ammoSkillId = self.getAmmoSkillId() while keepChanging: ammoSkillId += amt if ammoSkillId > InventoryType.DefenseCannonEmpty: ammoSkillId = InventoryType.DefenseCannonRoundShot if ammoSkillId < InventoryType.begin_WeaponSkillCannonDefense + 1: ammoSkillId = InventoryType.DefenseCannonEmpty inv = base.localAvatar.getInventory() if ammoSkillId > InventoryType.CannonBullet: keepChanging = False if inv.getStackQuantity(ammoSkillId) >= 2: keepChanging = False if WeaponGlobals.isInfiniteAmmo(ammoSkillId): keepChanging = False self.setAmmoSkillId(ammoSkillId) del ammoSkillId if WeaponGlobals.isInfiniteAmmo(self.getAmmoSkillId()): self.cgui.setAmmoLeft(-1, -1) else: ammoInvId = WeaponGlobals.getSkillAmmoInventoryId( self.getAmmoSkillId()) self.numShots = inv.getStackQuantity(ammoInvId) maxShots = inv.getStackLimit(ammoInvId) self.cgui.setAmmoLeft(self.numShots, maxShots) self.cgui.setAmmoId(self.getAmmoSkillId()) self.cgui.showCannonControls() self.updateCannonDressing() self.hideCannonDressing() self.setVolley(0)
def gotInventory(inv): if inv: ammoInvId = WeaponGlobals.getSkillAmmoInventoryId(self.getAmmoSkillId()) maxShots = inv.getStackLimit(ammoInvId) self.numShots = inv.getStackQuantity(ammoInvId) if WeaponGlobals.isInfiniteAmmo(self.getAmmoSkillId()) or WeaponGlobals.canUseInfiniteAmmo(localAvatar.getCurrentCharm(), self.getAmmoSkillId()): self.cgui.setAmmoLeft(-1, -1) else: self.cgui.setAmmoLeft(self.numShots, maxShots) self.updateCannonItems() self.updateCannonDressing()
def startReload(self, elapsedTime=0): if self.numShots == 0 and not WeaponGlobals.isInfiniteAmmo( self.getAmmoSkillId( )) and not WeaponGlobals.canUseInfiniteAmmo( localAvatar.getCurrentCharm(), self.getAmmoSkillId()): return self.rechargeTime = self.cr.battleMgr.getModifiedReloadTime( localAvatar, self.skillId, self.getAmmoSkillId()) base.localAvatar.skillDiary.startRecharging(self.skillId, 0) self.cgui.startReload(self.rechargeTime, self.volley, elapsedTime=0, doneCallback=self.finishReload)
def startReload(self, elapsedTime = 0): if self.numShots == 0 and not WeaponGlobals.isInfiniteAmmo(self.getAmmoSkillId()) and not WeaponGlobals.canUseInfiniteAmmo(localAvatar.getCurrentCharm(), self.getAmmoSkillId()): return None self.rechargeTime = self.cr.battleMgr.getModifiedReloadTime(localAvatar, self.skillId, self.getAmmoSkillId()) base.localAvatar.skillDiary.startRecharging(self.skillId, 0) self.cgui.startReload(self.rechargeTime, self.volley, elapsedTime = 0, doneCallback = self.finishReload)
def playSkillSfx(self, skillId, node, startTime = 0, loud = 1): vol = 0.5 if loud: vol = 1.0 if self.isEmpty(): return None if self.getName() not in [ 'sword', 'pistol', 'daggers', 'grenade', 'fishingRod', 'bayonet', 'gun', 'doll']: return None sfxFunc = WeaponGlobals.getWeaponSfx(node.currentWeaponId, skillId) if not sfxFunc: sfx = self.skillSfxs.get(skillId) else: sfx = sfxFunc() if sfx: base.playSfx(sfx, node = node, cutoff = 60, time = startTime, volume = vol)
def getAreaList(self, skillId, ammoSkillId, target, pos, attackerId, isBoss = False): targets = set() areaShape = WeaponGlobals.getAttackAreaShape(skillId, ammoSkillId) bitmask = PiratesGlobals.GenericShipBitmask if areaShape == WeaponGlobals.AREA_SPHERE: self.runSphereAreaCollisions(skillId, ammoSkillId, target, pos, bitmask) elif areaShape == WeaponGlobals.AREA_TUBE: self.runTubeAreaCollisions(skillId, ammoSkillId, target, pos, bitmask) elif areaShape == WeaponGlobals.AREA_CONE: self.runConeAreaCollisions(skillId, ammoSkillId, target, pos, bitmask) elif areaShape == WeaponGlobals.AREA_OFF: return [] numEntries = self.areaCollQueue.getNumEntries() if numEntries == 0: return [] for i in range(numEntries): areaTarget = self.areaCollQueue.getEntry(i).getIntoNodePath().getNetPythonTag('ship') if areaTarget.gameFSM.state in ('Sinking', 'Sunk'): continue targets.add(areaTarget.doId) if target in targets: targets.remove(target) return list(targets)
def _doFireCannon(self): if self.volley > 0: localAvatar.lastCannonShot = globalClock.getFrameTime() h = self.prop.hNode.getH(render) p = self.prop.pivot.getP(render) r = 0 pos = self.prop.cannonExitPoint.getPos(render) posHpr = [pos[0], pos[1], pos[2], h, p, r] charge = 0.0 timestamp = globalClockDelta.getFrameNetworkTime(bits=32) self.sendRequestProjectileSkill(self.skillId, self.getAmmoSkillId(), posHpr, charge, timestamp) self.prop.playAttack(self.skillId, self.getAmmoSkillId(), self.projectileHitEvent, buffs=localAvatar.getSkillEffects(), shotNum=self.shotNum) self.setVolley(self.volley - 1) if not WeaponGlobals.isInfiniteAmmo( self.getAmmoSkillId()) and not base.config.GetBool( 'infinite-ammo', 0) and not WeaponGlobals.canUseInfiniteAmmo( localAvatar.getCurrentCharm(), self.getAmmoSkillId()): inv = base.localAvatar.getInventory() ammoInvId = WeaponGlobals.getSkillAmmoInventoryId( self.getAmmoSkillId()) maxShots = inv.getStackLimit(ammoInvId) self.numShots -= 1 self.cgui.setAmmoLeft(self.numShots, maxShots) self.hideCannonDressing() else: base.playSfx(self.emptySound) if localAvatar.guiMgr.combatTray.skillTray.traySkillMap: for i in range( len(localAvatar.guiMgr.combatTray.skillTray.traySkillMap)): if localAvatar.guiMgr.combatTray.skillTray.traySkillMap[ i] == self.getAmmoSkillId(): button = localAvatar.guiMgr.combatTray.skillTray.tray[i + 1] if button.skillStatus is True: button.updateQuantity(self.numShots) button.skillStatus is True
def changeAmmo(self, amt=1): if amt == 0: return None keepChanging = True ammoSkillId = self.getAmmoSkillId() while keepChanging: ammoSkillId += amt if ammoSkillId > InventoryType.CannonGrappleHook: ammoSkillId = InventoryType.CannonRoundShot if ammoSkillId < InventoryType.begin_WeaponSkillCannon + 1: ammoSkillId = InventoryType.CannonGrappleHook inv = base.localAvatar.getInventory() if ammoSkillId > InventoryType.CannonBullet: keepChanging = False if inv and inv.getStackQuantity(ammoSkillId) >= 2: keepChanging = False if WeaponGlobals.isInfiniteAmmo( ammoSkillId) or WeaponGlobals.canUseInfiniteAmmo( localAvatar.getCurrentCharm(), ammoSkillId): keepChanging = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): if not WeaponGlobals.canFreeUse(ammoSkillId): keepChanging = True WeaponGlobals.canFreeUse(ammoSkillId) self.setAmmoSkillId(ammoSkillId) del ammoSkillId if WeaponGlobals.isInfiniteAmmo( self.getAmmoSkillId()) or WeaponGlobals.canUseInfiniteAmmo( localAvatar.getCurrentCharm(), self.getAmmoSkillId()): self.cgui.setAmmoLeft(-1, -1) elif inv: ammoInvId = WeaponGlobals.getSkillAmmoInventoryId( self.getAmmoSkillId()) self.numShots = inv.getStackQuantity(ammoInvId) maxShots = inv.getStackLimit(ammoInvId) self.cgui.setAmmoLeft(self.numShots, maxShots) self.cgui.setAmmoId(self.getAmmoSkillId()) self.updateCannonDressing() self.hideCannonDressing() self.setVolley(0)
def changeAmmo(self, amt = 1): if amt == 0: return None keepChanging = True ammoSkillId = self.getAmmoSkillId() while keepChanging: ammoSkillId += amt if ammoSkillId > InventoryType.DefenseCannonEmpty: ammoSkillId = InventoryType.DefenseCannonRoundShot if ammoSkillId < InventoryType.begin_WeaponSkillCannonDefense + 1: ammoSkillId = InventoryType.DefenseCannonEmpty inv = base.localAvatar.getInventory() if ammoSkillId > InventoryType.CannonBullet: keepChanging = False if inv.getStackQuantity(ammoSkillId) >= 2: keepChanging = False if WeaponGlobals.isInfiniteAmmo(ammoSkillId): keepChanging = False continue self.setAmmoSkillId(ammoSkillId) del ammoSkillId if WeaponGlobals.isInfiniteAmmo(self.getAmmoSkillId()): self.cgui.setAmmoLeft(-1, -1) else: ammoInvId = WeaponGlobals.getSkillAmmoInventoryId(self.getAmmoSkillId()) self.numShots = inv.getStackQuantity(ammoInvId) maxShots = inv.getStackLimit(ammoInvId) self.cgui.setAmmoLeft(self.numShots, maxShots) self.cgui.setAmmoId(self.getAmmoSkillId()) self.cgui.showCannonControls() self.updateCannonDressing() self.hideCannonDressing() self.setVolley(0)
def _doFireCannon(self): if self.volley > 0: localAvatar.lastCannonShot = globalClock.getFrameTime() h = self.prop.hNode.getH(render) p = self.prop.pivot.getP(render) r = 0 pos = self.prop.cannonExitPoint.getPos(render) posHpr = [ pos[0], pos[1], pos[2], h, p, r] charge = 0.0 timestamp = globalClockDelta.getFrameNetworkTime(bits = 32) self.sendRequestProjectileSkill(self.skillId, self.getAmmoSkillId(), posHpr, charge, timestamp) self.prop.playAttack(self.skillId, self.getAmmoSkillId(), self.projectileHitEvent, buffs = localAvatar.getSkillEffects(), shotNum = self.shotNum) self.setVolley(self.volley - 1) if not WeaponGlobals.isInfiniteAmmo(self.getAmmoSkillId()) and not base.config.GetBool('infinite-ammo', 0) and not WeaponGlobals.canUseInfiniteAmmo(localAvatar.getCurrentCharm(), self.getAmmoSkillId()): inv = base.localAvatar.getInventory() ammoInvId = WeaponGlobals.getSkillAmmoInventoryId(self.getAmmoSkillId()) maxShots = inv.getStackLimit(ammoInvId) self.numShots -= 1 self.cgui.setAmmoLeft(self.numShots, maxShots) self.hideCannonDressing() else: base.playSfx(self.emptySound) if localAvatar.guiMgr.combatTray.skillTray.traySkillMap: for i in range(len(localAvatar.guiMgr.combatTray.skillTray.traySkillMap)): if localAvatar.guiMgr.combatTray.skillTray.traySkillMap[i] == self.getAmmoSkillId(): button = localAvatar.guiMgr.combatTray.skillTray.tray[i + 1] if button.skillStatus is True: button.updateQuantity(self.numShots) button.skillStatus is True
def changeAmmo(self, amt = 1): if amt == 0: return None keepChanging = True ammoSkillId = self.getAmmoSkillId() while keepChanging: ammoSkillId += amt if ammoSkillId > InventoryType.CannonGrappleHook: ammoSkillId = InventoryType.CannonRoundShot if ammoSkillId < InventoryType.begin_WeaponSkillCannon + 1: ammoSkillId = InventoryType.CannonGrappleHook inv = base.localAvatar.getInventory() if ammoSkillId > InventoryType.CannonBullet: keepChanging = False if inv and inv.getStackQuantity(ammoSkillId) >= 2: keepChanging = False if WeaponGlobals.isInfiniteAmmo(ammoSkillId) or WeaponGlobals.canUseInfiniteAmmo(localAvatar.getCurrentCharm(), ammoSkillId): keepChanging = False if not Freebooter.getPaidStatus(base.localAvatar.getDoId()): if not WeaponGlobals.canFreeUse(ammoSkillId): keepChanging = True WeaponGlobals.canFreeUse(ammoSkillId) self.setAmmoSkillId(ammoSkillId) del ammoSkillId if WeaponGlobals.isInfiniteAmmo(self.getAmmoSkillId()) or WeaponGlobals.canUseInfiniteAmmo(localAvatar.getCurrentCharm(), self.getAmmoSkillId()): self.cgui.setAmmoLeft(-1, -1) elif inv: ammoInvId = WeaponGlobals.getSkillAmmoInventoryId(self.getAmmoSkillId()) self.numShots = inv.getStackQuantity(ammoInvId) maxShots = inv.getStackLimit(ammoInvId) self.cgui.setAmmoLeft(self.numShots, maxShots) self.cgui.setAmmoId(self.getAmmoSkillId()) self.updateCannonDressing() self.hideCannonDressing() self.setVolley(0)
def __init__(self, cr): DistributedWeapon.DistributedWeapon.__init__(self, cr) self.ship = None self.tutorial = 0 self.prop = None self.baseVel = Vec3(0) self.mouseX = 0 self.mouseY = 0 self.setPos(0, 0, 0) self.moveCannon = 0 self.av = None self.ball = None self.ship = None self.shipId = None self.tubeNP = None self.cgui = None self.numShots = 0 self.grapplingHook = None self.cannonDressingNode = NodePath(ModelNode('dressingNode')) self._cameraState = 'Cannon' self.collisionLists = {} self.listening = False self.skillId = InventoryType.CannonShoot self.reloadTime = 0 self.rechargeTime = 0 self.volley = WeaponGlobals.getAttackVolley(self.skillId, self.getAmmoSkillId()) self.modeFSM = ClassicFSM.ClassicFSM('modeFSM', [ State.State('off', self.enterOff, self.exitOff), State.State('fireCannon', self.enterFireCannon, self.exitFireCannon), State.State('tutorialCutscene', self.enterTutorialCutscene, self.exitTutorialCutscene) ], 'off', 'off') self.modeFSM.enterInitialState() self.aimAITrack = None self.headingNode = NodePath('dummy') OTPRender.renderReflection(False, self, 'p_cannon', None) if not self.emptySound: DistributedPCCannon.emptySound = loadSfx( SoundGlobals.SFX_WEAPON_CANNON_EMPTY) self.fireSubframeCall = None self.__invRequest = None self.shotNum = -1 return
def __init__(self, cr): DistributedWeapon.DistributedWeapon.__init__(self, cr) self.ship = None self.tutorial = 0 self.prop = None self.baseVel = Vec3(0) self.mouseX = 0 self.mouseY = 0 self.setPos(0, 0, 0) self.moveCannon = 0 self.av = None self.ball = None self.ship = None self.shipId = None self.tubeNP = None self.cgui = None self.numShots = 0 self.grapplingHook = None self.cannonDressingNode = NodePath(ModelNode('dressingNode')) self._cameraState = 'Cannon' self.collisionLists = { } self.listening = False self.skillId = InventoryType.CannonShoot self.reloadTime = 0 self.rechargeTime = 0 self.volley = WeaponGlobals.getAttackVolley(self.skillId, self.getAmmoSkillId()) self.modeFSM = ClassicFSM.ClassicFSM('modeFSM', [ State.State('off', self.enterOff, self.exitOff), State.State('fireCannon', self.enterFireCannon, self.exitFireCannon), State.State('tutorialCutscene', self.enterTutorialCutscene, self.exitTutorialCutscene)], 'off', 'off') self.modeFSM.enterInitialState() self.aimAITrack = None self.headingNode = NodePath('dummy') OTPRender.renderReflection(False, self, 'p_cannon', None) if not self.emptySound: DistributedPCCannon.emptySound = loadSfx(SoundGlobals.SFX_WEAPON_CANNON_EMPTY) self.fireSubframeCall = None self._DistributedPCCannon__invRequest = None self.shotNum = -1
def getAreaList(self, skillId, ammoSkillId, target, pos, attackerId, isBoss=False): targets = set() areaShape = WeaponGlobals.getAttackAreaShape(skillId, ammoSkillId) bitmask = PiratesGlobals.GenericShipBitmask if areaShape == WeaponGlobals.AREA_SPHERE: self.runSphereAreaCollisions(skillId, ammoSkillId, target, pos, bitmask) elif areaShape == WeaponGlobals.AREA_TUBE: self.runTubeAreaCollisions(skillId, ammoSkillId, target, pos, bitmask) elif areaShape == WeaponGlobals.AREA_CONE: self.runConeAreaCollisions(skillId, ammoSkillId, target, pos, bitmask) elif areaShape == WeaponGlobals.AREA_OFF: return [] numEntries = self.areaCollQueue.getNumEntries() if numEntries == 0: return [] for i in range(numEntries): areaTarget = self.areaCollQueue.getEntry( i).getIntoNodePath().getNetPythonTag('ship') if areaTarget.gameFSM.state in ('Sinking', 'Sunk'): continue targets.add(areaTarget.doId) if target in targets: targets.remove(target) return list(targets)
def getAreaList(self, skillId, ammoSkillId, target, pos, attackerId, isBoss=False): targets = [] areaShape = WeaponGlobals.getAttackAreaShape(skillId, ammoSkillId) if areaShape == WeaponGlobals.AREA_SPHERE: self.runSphereAreaCollisions(skillId, ammoSkillId, target, pos) elif areaShape == WeaponGlobals.AREA_TUBE: self.runTubeAreaCollisions(skillId, ammoSkillId, target, pos) elif areaShape == WeaponGlobals.AREA_CONE: self.runConeAreaCollisions(skillId, ammoSkillId, target, pos) elif areaShape == WeaponGlobals.AREA_OFF: return targets numEntries = self.areaCollQueue.getNumEntries() if numEntries == 0: return targets if isBoss and numEntries > WeaponGlobals.BOSS_AREA_TARGETS: numEntries = WeaponGlobals.BOSS_AREA_TARGETS elif numEntries > WeaponGlobals.MAX_AREA_TARGETS: numEntries = WeaponGlobals.MAX_AREA_TARGETS avTeam = self.avatar.getTeam() for i in range(numEntries): entry = self.areaCollQueue.getEntry(i) potentialTargetColl = entry.getIntoNodePath() if potentialTargetColl in self.avatar.aimTubeNodePaths: potentialTarget = self.avatar else: potentialTarget = self.repository.targetMgr.getObjectFromNodepath( potentialTargetColl) if potentialTarget: potentialTargetId = potentialTarget.getDoId() if potentialTargetId == target.getDoId(): continue if potentialTargetId in targets: continue if not WeaponGlobals.isFriendlyFire(skillId, ammoSkillId): if not TeamUtils.damageAllowed(potentialTarget, self.avatar): if attackerId and potentialTargetId == attackerId: if not WeaponGlobals.isAttackAreaSelfDamaging( skillId, ammoSkillId): continue elif attackerId and potentialTargetId == attackerId: if not WeaponGlobals.isAttackAreaSelfDamaging( skillId, ammoSkillId): continue if TeamUtils.damageAllowed(potentialTarget, self.avatar): skillEffect = WeaponGlobals.getSkillEffectFlag(skillId) if skillEffect != WeaponGlobals.C_ATTUNE: continue if potentialTarget.gameFSM.state == 'Death': continue if potentialTarget.gameFSM.state in ('BenchRepair', 'PotionCrafting', 'Fishing'): continue if not self.repository.battleMgr.obeysPirateCode( self.avatar, potentialTarget): if ItemGlobals.getSubtype(localAvatar.currentWeaponId ) == ItemGlobals.BAYONET: pass if not (WeaponGlobals.getAttackClass(skillId) == WeaponGlobals.AC_COMBAT): continue targets.append(potentialTargetId) continue continue return targets
def getAreaList(self, skillId, ammoSkillId, target, pos, attackerId, isBoss = False): targets = [] areaShape = WeaponGlobals.getAttackAreaShape(skillId, ammoSkillId) if areaShape == WeaponGlobals.AREA_SPHERE: self.runSphereAreaCollisions(skillId, ammoSkillId, target, pos) elif areaShape == WeaponGlobals.AREA_TUBE: self.runTubeAreaCollisions(skillId, ammoSkillId, target, pos) elif areaShape == WeaponGlobals.AREA_CONE: self.runConeAreaCollisions(skillId, ammoSkillId, target, pos) elif areaShape == WeaponGlobals.AREA_OFF: return targets numEntries = self.areaCollQueue.getNumEntries() if numEntries == 0: return targets if isBoss and numEntries > WeaponGlobals.BOSS_AREA_TARGETS: numEntries = WeaponGlobals.BOSS_AREA_TARGETS elif numEntries > WeaponGlobals.MAX_AREA_TARGETS: numEntries = WeaponGlobals.MAX_AREA_TARGETS avTeam = self.avatar.getTeam() for i in range(numEntries): entry = self.areaCollQueue.getEntry(i) potentialTargetColl = entry.getIntoNodePath() if potentialTargetColl in self.avatar.aimTubeNodePaths: potentialTarget = self.avatar else: potentialTarget = self.repository.targetMgr.getObjectFromNodepath(potentialTargetColl) if potentialTarget: potentialTargetId = potentialTarget.getDoId() if potentialTargetId == target.getDoId(): continue if potentialTargetId in targets: continue if not WeaponGlobals.isFriendlyFire(skillId, ammoSkillId): if not TeamUtils.damageAllowed(potentialTarget, self.avatar): if attackerId and potentialTargetId == attackerId: if not WeaponGlobals.isAttackAreaSelfDamaging(skillId, ammoSkillId): continue elif attackerId and potentialTargetId == attackerId: if not WeaponGlobals.isAttackAreaSelfDamaging(skillId, ammoSkillId): continue if TeamUtils.damageAllowed(potentialTarget, self.avatar): skillEffect = WeaponGlobals.getSkillEffectFlag(skillId) if skillEffect != WeaponGlobals.C_ATTUNE: continue if potentialTarget.gameFSM.state == 'Death': continue if potentialTarget.gameFSM.state in ('BenchRepair', 'PotionCrafting', 'Fishing'): continue if not self.repository.battleMgr.obeysPirateCode(self.avatar, potentialTarget): if ItemGlobals.getSubtype(localAvatar.currentWeaponId) == ItemGlobals.BAYONET: pass if not (WeaponGlobals.getAttackClass(skillId) == WeaponGlobals.AC_COMBAT): continue targets.append(potentialTargetId) continue continue return targets