示例#1
0
    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 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 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 _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