def handleEnterMole(self, colEntry):
     if not self.gameStarted:
         self.notify.debug('sending clientTriggered for %d' % self.doId)
         self.sendUpdate('setClientTriggered', [])
     
     surfaceNormal = colEntry.getSurfaceNormal(render)
     self.notify.debug('surfaceNormal=%s' % surfaceNormal)
     into = colEntry.getIntoNodePath()
     moleIndex = int(into.getName().split('-')[-1])
     self.notify.debug('hit mole %d' % moleIndex)
     moleHill = self.moleHills[moleIndex]
     moleHill.stashMoleCollision()
     popupNum = moleHill.getPopupNum()
     if moleHill.hillType == MoleFieldBase.HILL_MOLE:
         timestamp = globalClockDelta.getFrameNetworkTime()
         moleHill.setHillType(MoleFieldBase.HILL_WHACKED)
         self.sendUpdate('whackedBomb', [
             moleIndex,
             popupNum,
             timestamp])
         self._DistributedMoleField__showToonHitByBomb(localAvatar.doId, moleIndex, timestamp)
     elif moleHill.hillType == MoleFieldBase.HILL_BOMB:
         moleHill.setHillType(MoleFieldBase.HILL_COGWHACKED)
         self.soundCog.play()
         self.sendUpdate('whackedMole', [
             moleIndex,
             popupNum])
 def enterWaitClientsChoices(self):
     self.notify.debug('enterWaitClientsChoices')
     self.resetChoices()
     self.sendUpdate('setMatchAndRound', [self.curMatch, self.curRound])
     self.sendUpdate('setNewState', ['inputChoice'])
     taskMgr.doMethodLater(IceGameGlobals.InputTimeout, self.waitClientsChoicesTimeout, self.taskName('wait-choices-timeout'))
     self.sendUpdate('setTimerStartTime', [globalClockDelta.getFrameNetworkTime()])
示例#3
0
 def damageTaken(self, amount, avId):
     if self.fsm.getCurrentState().getName() == 'dead' and self.hp <= 0:
         return
     self.hp -= amount
     if self.fsm.getCurrentState().getName() != 'dead' and self.hp <= 0:
         self.mg.sendUpdate('dead', [avId])
     if self.hp <= 0.0:
         timestamp = globalClockDelta.getFrameNetworkTime()
         self.mg.sendUpdate('deadAvatar', [base.localAvatar.doId, timestamp])
     ToonFPS.ToonFPS.damageTaken(self, amount, avId)
示例#4
0
 def d_startProjInterval(self, startPos, endPos, duration, gravityMult):
     timestamp = globalClockDelta.getFrameNetworkTime()
     self.sendUpdate('startProjInterval', [startPos.getX(),
      startPos.getY(),
      startPos.getZ(),
      endPos.getX(),
      endPos.getY(),
      endPos.getZ(),
      duration,
      gravityMult,
      timestamp])
示例#5
0
 def d_startPosInterval(self, startPos, endPos, duration, blendType):
     timestamp = globalClockDelta.getFrameNetworkTime()
     self.sendUpdate('startPosInterval', [startPos.getX(),
      startPos.getY(),
      startPos.getZ(),
      endPos.getX(),
      endPos.getY(),
      endPos.getZ(),
      duration,
      blendType,
      timestamp])
    def _WeaponBase__groundHit(self, groundId, hitObject, entry, skillId, ammoSkillId):
        if self.ignoreGround:
            return None

        ground = self.cr.doId2do.get(groundId)
        if not ground:
            return None

        pos = entry.getSurfacePoint(ground)
        normal = entry.getSurfaceNormal(ground)
        if self.localAvatarUsingWeapon:
            codes = []
            timestamp32 = globalClockDelta.getFrameNetworkTime(bits=32)
            attackerId = 0
            attackerStr = entry.getFromNodePath().getNetTag("attackerId")
            if attackerStr:
                attackerId = int(attackerStr)

            attacker = self.cr.doId2do.get(attackerId)
            if not attacker:
                return None

            groundCode = 0
            groundCodeStr = hitObject.getNetTag("groundCode")
            if groundCodeStr:
                groundCode = int(groundCodeStr)

            areaList = self.getAreaList(skillId, ammoSkillId, ground, pos, attackerId)
            result = self.cr.battleMgr.doAttack(attacker, skillId, ammoSkillId, groundId, areaList, pos)
            self.sendSuggestProjectileSkillResult(
                skillId,
                ammoSkillId,
                result,
                groundId,
                areaList,
                [pos[0], pos[1], pos[2]],
                [normal[0], normal[1], normal[2]],
                codes,
                timestamp32,
            )
            for doId in [groundId] + areaList:
                target = self.cr.doId2do.get(doId)
                if not target:
                    continue

                (attackerEffects, targetEffects, itemEffects) = self.cr.battleMgr.getModifiedSkillEffects(
                    attacker, target, skillId, ammoSkillId
                )
                target.projectileWeaponHit(
                    skillId, ammoSkillId, result, targetEffects, pos, normal, codes, attacker, itemEffects
                )
    def _WeaponBase__avatarHit(self, avId, hitObject, entry, skillId, ammoSkillId):
        av = self.cr.doId2do.get(avId)
        if av and self.localAvatarUsingWeapon:
            codes = []
            pos = entry.getSurfacePoint(av)
            normal = entry.getSurfaceNormal(render)
            timestamp32 = globalClockDelta.getFrameNetworkTime(bits=32)
            attackerId = 0
            attackerStr = entry.getFromNodePath().getNetTag("attackerId")
            if attackerStr:
                attackerId = int(attackerStr)

            attacker = self.cr.doId2do.get(attackerId)
            if not attacker:
                return None

            if not TeamUtils.damageAllowed(attacker, av):
                if hasattr(attacker, "getName") and hasattr(av, "getName"):
                    pass
                1
                return None

            areaList = self.getAreaList(skillId, ammoSkillId, av, pos, attackerId)
            result = self.cr.battleMgr.doAttack(attacker, skillId, ammoSkillId, avId, areaList, pos)
            self.sendSuggestProjectileSkillResult(
                skillId,
                ammoSkillId,
                result,
                avId,
                areaList,
                [pos[0], pos[1], pos[2]],
                [normal[0], normal[1], normal[2]],
                codes,
                timestamp32,
            )
            for doId in [avId] + areaList:
                target = self.cr.doId2do.get(doId)
                (attackerEffects, targetEffects, itemEffects) = self.cr.battleMgr.getModifiedSkillEffects(
                    attacker, target, skillId, ammoSkillId
                )
                target.projectileWeaponHit(
                    skillId, ammoSkillId, result, targetEffects, pos, normal, codes, attacker, itemEffects
                )
示例#8
0
 def enter(self):
     SuitHabitualBehavior.enter(self)
     self.__toggleCanHeal()
     attack = random.randint(0, 6)
     attackName = SuitAttacks.SuitAttackLengths.keys()[attack]
     timestamp = globalClockDelta.getFrameNetworkTime()
     self.suit.sendUpdate('doAttack', [attack, self.boss.doId, timestamp])
     distance = self.suit.getDistance(self.boss)
     timeUntilHeal = distance / self.HEAL_SPEED
     timeUntilRelease = 1.0
     self.suit.d_setChat(CIGlobals.SuitHealTaunt)
     hp = random.randint(self.minHeal, self.maxHeal)
     if self.boss.getHealth() + hp > self.boss.getMaxHealth():
         hp = self.boss.getMaxHealth() - self.boss.getHealth()
     if attackName != 'glowerpower':
         if self.suit.suitPlan.getSuitType() == 'C':
             timeUntilRelease = 2.2
         else:
             timeUntilRelease = 3.0
     self.suitHealTrack = Sequence(Func(self.__disableBoss), Wait(timeUntilRelease + timeUntilHeal), Func(self.__attemptToHealBoss, hp), Func(self.__enableBoss), Func(self.exit))
     self.suitHealTrack.start()
 def _DistributedGolfSpot__flyBallHit(self, entry):
     if not entry.hasSurfacePoint() or not entry.hasInto():
         return None
     
     if not entry.getInto().isTangible():
         return None
     
     sequence = int(entry.getFromNodePath().getNetTag('pieSequence'))
     self._DistributedGolfSpot__finishFlyBallTrack(sequence)
     if self.splatTracks.has_key(sequence):
         splatTrack = self.splatTracks[sequence]
         del self.splatTracks[sequence]
         splatTrack.finish()
     
     flyBallCode = 0
     flyBallCodeStr = entry.getIntoNodePath().getNetTag('pieCode')
     if flyBallCodeStr:
         flyBallCode = int(flyBallCodeStr)
     
     pos = entry.getSurfacePoint(render)
     timestamp32 = globalClockDelta.getFrameNetworkTime(bits = 32)
     throwerId = int(entry.getFromNodePath().getNetTag('throwerId'))
     splat = self.getFlyBallSplatInterval(pos[0], pos[1], pos[2], flyBallCode, throwerId)
     splat = Sequence(splat, Func(self.flyBallFinishedSplatting, sequence))
     self.splatTracks[sequence] = splat
     splat.start()
     self.notify.debug('doId=%d into=%s flyBallCode=%d, throwerId=%d' % (self.doId, entry.getIntoNodePath(), flyBallCode, throwerId))
     if flyBallCode == ToontownGlobals.PieCodeBossCog and self.avId == localAvatar.doId and self.lastHitSequenceNum != self._DistributedGolfSpot__flyBallSequenceNum:
         self.lastHitSequenceNum = self._DistributedGolfSpot__flyBallSequenceNum
         self.boss.d_ballHitBoss(1)
     elif flyBallCode == ToontownGlobals.PieCodeToon and self.avId == localAvatar.doId and self.lastHitSequenceNum != self._DistributedGolfSpot__flyBallSequenceNum:
         self.lastHitSequenceNum = self._DistributedGolfSpot__flyBallSequenceNum
         avatarDoId = entry.getIntoNodePath().getNetTag('avatarDoId')
         if avatarDoId == '':
             self.notify.warning('Toon %s has no avatarDoId tag.' % repr(entry.getIntoNodePath()))
             return None
         
         doId = int(avatarDoId)
         if doId != localAvatar.doId:
             pass
 def __doAttack(self, task):
     base.taskMgr.remove(self.uniqueName('scwaa'))
     target = self.air.doId2do.get(self.avatarId)
     if not target:
         return task.done
     self.clearTrack()
     self.b_setSuitState(0, -1, -1)
     self.b_setAnimState('neutral')
     self.headsUp(target)
     attack = random.choice(self.suitPlan.getAttacks())
     attackIndex = SuitAttacks.SuitAttackLengths.keys().index(attack)
     attackTaunt = random.randint(0, len(CIGlobals.SuitAttackTaunts[attack]) - 1)
     timestamp = globalClockDelta.getFrameNetworkTime()
     if self.isDead():
         self.stopAttacks()
         return task.done
     self.sendUpdate('doAttack', [attackIndex, target.doId, timestamp])
     self.d_setChat(CIGlobals.SuitAttackTaunts[attack][attackTaunt])
     attackLength = SuitAttacks.SuitAttackLengths[attack]
     base.taskMgr.doMethodLater(attackLength, self.__suitContinueWalkAfterAttack, self.uniqueName('scwaa'))
     task.delayTime = random.randint(*self.ATTACK_IVAL_RANGE)
     return task.again
示例#11
0
 def startAttacking(self, task = None):
     if hasattr(self.suit, 'DELETED') or not hasattr(self, 'attacksThisSession'):
         self.stopAttacking()
         if task:
             return Task.done
     if self.attacksThisSession > 0:
         self.resetAvatarsInRange()
     if hasattr(self.suit, 'DELETED'):
         self.stopAttacking()
         return
     from lib.coginvasion.cog.SuitPanicBehavior import SuitPanicBehavior
     brain = self.suit.getBrain()
     panicBehavior = brain.getBehavior(SuitPanicBehavior)
     healthPerct = float(self.suit.getHealth()) / float(self.suit.getMaxHealth())
     origHealthPerct = float(self.origHealth) / float(self.suit.getMaxHealth())
     if len(self.avatarsInRange) < 1 or panicBehavior and healthPerct <= panicBehavior.getPanicHealthPercentage() or healthPerct - origHealthPerct >= self.ABANDON_ATTACK_PERCT:
         self.stopAttacking()
         return
     target = self.avatarsInRange[0]
     self.suit.b_setAnimState('neutral')
     self.suit.headsUp(target)
     attack = random.choice(self.suit.suitPlan.getAttacks())
     attackIndex = SuitAttacks.SuitAttackLengths.keys().index(attack)
     timestamp = globalClockDelta.getFrameNetworkTime()
     if self.suit.isDead():
         self.stopAttacking()
         return
     self.suit.sendUpdate('doAttack', [attackIndex, target.doId, timestamp])
     self.isAttacking = True
     self.attacksThisSession += 1
     self.attacksDone += 1
     self.ATTACK_COOLDOWN = SuitAttacks.SuitAttackLengths[attack]
     if self.attacksThisSession < self.maxAttacksPerSession:
         taskMgr.doMethodLater(self.ATTACK_COOLDOWN, self.startAttacking, self.suit.uniqueName('attackTask'))
     else:
         taskMgr.doMethodLater(self.ATTACK_COOLDOWN, self.stopAttacking, self.suit.uniqueName('finalAttack'))
     if task:
         return Task.done
示例#12
0
 def _WeaponBase__grappleTargetHit(self, shipId, hitObject, entry, skillId, ammoSkillId):
     sequence = int(entry.getFromNodePath().getNetTag('ammoSequence'))
     ship = self.cr.doId2do.get(shipId)
     if not ship:
         return None
     else:
         targetIndex = int(hitObject.getNetTag('targetId')[-1:])
         codes = [
             99,
             targetIndex,
             0]
         pos = entry.getSurfacePoint(ship)
         normal = entry.getSurfaceNormal(render)
         timestamp32 = globalClockDelta.getFrameNetworkTime(bits = 32)
         areaList = []
         result = WeaponGlobals.RESULT_HIT
         self.sendSuggestProjectileSkillResult(skillId, ammoSkillId, result, shipId, areaList, [
             pos[0],
             pos[1],
             pos[2]], [
             normal[0],
             normal[1],
             normal[2]], codes, timestamp32)
    def simpleShipHit(self, hitObject, entry, skillId, ammoSkillId):
        timestamp32 = globalClockDelta.getFrameNetworkTime(bits=32)
        ship = hitObject.getNetPythonTag("ship")
        if not ship:
            self.notify.warning("ignoring attack on destroyed ship")
            return None

        attackerShipId = entry.getFromNodePath().getNetTag("shipId")
        hullCode = hitObject.getNetTag("Hull Code")
        if hullCode:
            hullCode = int(hullCode)
        else:
            hullCode = 255
        mastCode = hitObject.getNetTag("Mast Code")
        hitSail = hitObject.getNetTag("Sail")
        if not hitSail:
            hitSail = 0
        else:
            hitSail = 1
        if mastCode:
            mastCode = int(mastCode)
        else:
            mastCode = 255
        pos = entry.getSurfacePoint(ship)
        normal = entry.getSurfaceNormal(render)
        attackerId = 0
        attackerStr = entry.getFromNodePath().getNetTag("attackerId")
        if attackerStr:
            attackerId = int(attackerStr)

        attacker = self.cr.doId2do.get(attackerId)
        if not attacker:
            return None

        if attackerShipId:
            if int(attackerShipId) == ship.doId:
                return None

        if not TeamUtils.damageAllowed(attacker, ship):
            if TeamUtils.friendOrFoe(attacker, ship) == PiratesGlobals.PVP_FRIEND:
                localAvatar.guiMgr.createWarning(PLocalizer.TeamFireWarning, PiratesGuiGlobals.TextFG6)
            else:
                localAvatar.guiMgr.createWarning(PLocalizer.FriendlyFireWarning, PiratesGuiGlobals.TextFG6)
            attacker.battleRandom.advanceAttackSeed()
            return None

        if ship:
            ship.validateMastCode(mastCode)

        result = self.cr.battleMgr.doAttack(attacker, skillId, ammoSkillId, ship.doId, [], pos)
        ammo = entry.getFromNodePath().getNetPythonTag("ammo")
        if ammo:
            if ammo.hasTag("newAmmoId"):
                ammoSkillId = int(ammo.getTag("newAmmoId"))
                pos = (0, 0, 0)

        self.sendSuggestProjectileSkillResult(
            skillId,
            ammoSkillId,
            result,
            ship.doId,
            [],
            [pos[0], pos[1], pos[2]],
            [normal[0], normal[1], normal[2]],
            [hullCode, mastCode, hitSail],
            timestamp32,
        )
        (attackerEffects, targetEffects, itemEffects) = self.cr.battleMgr.getModifiedSkillEffects(
            attacker, ship, skillId, ammoSkillId
        )
        ship.projectileWeaponHit(
            skillId,
            ammoSkillId,
            result,
            targetEffects,
            pos,
            normal,
            (hullCode, mastCode, hitSail),
            attacker,
            itemEffects,
        )
        return True
 def startRewardSeq(self):
     timestamp = globalClockDelta.getFrameNetworkTime()
     self.sendUpdate('startRewardSeq', [timestamp])
示例#15
0
 def b_setMeal(self, meal):
     local_time = globalClock.getFrameTime()
     net_time = globalClockDelta.localToNetworkTime(local_time)
     net_time = globalClockDelta.getFrameNetworkTime()
     self.d_setMeal(meal, net_time)
     self.setMeal(meal, local_time)
 def _WeaponBase__shippartHit(self, hitObject, entry, skillId, ammoSkillId):
     shipId = hitObject.getNetTag('shipId')
     if shipId:
         shipId = int(shipId)
         ship = base.cr.doId2do.get(shipId)
         if ship:
             if ship.queryGameState() in ('FadeOut', 'Sinking', 'Inactive'):
                 return None
             
         else:
             return None
         fromNodePath = entry.getFromNodePath()
         attackerShipId = fromNodePath.getNetTag('shipId')
         if attackerShipId:
             attackerShipId = int(attackerShipId)
             if attackerShipId == shipId:
                 return None
             
         
         attackerId = 0
         attackerStr = entry.getFromNodePath().getNetTag('attackerId')
         if attackerStr:
             attackerId = int(attackerStr)
             attacker = self.cr.doId2do.get(attackerId)
             if not attacker:
                 return None
             
         else:
             return None
         cannonCode = 0
         cannonCodeStr = hitObject.getNetTag('cannonCode')
         if cannonCodeStr:
             cannonCode = int(cannonCodeStr)
         
         hullCode = 0
         hullCodeStr = hitObject.getNetTag('hullCode')
         if hullCodeStr:
             hullCode = int(hullCodeStr)
         
         sailCode = 0
         sailCodeStr = hitObject.getNetTag('sailCode')
         if sailCodeStr:
             sailCode = int(sailCodeStr)
         
         codes = [
             cannonCode,
             hullCode,
             sailCode]
         pos = entry.getSurfacePoint(ship)
         normal = entry.getSurfaceNormal(render)
         timestamp32 = globalClockDelta.getFrameNetworkTime(bits = 32)
         if not TeamUtils.damageAllowed(attacker, ship):
             if TeamUtils.friendOrFoe(attacker, ship) == PiratesGlobals.PVP_FRIEND:
                 localAvatar.guiMgr.createWarning(PLocalizer.TeamFireWarning, PiratesGuiGlobals.TextFG6)
             else:
                 localAvatar.guiMgr.createWarning(PLocalizer.FriendlyFireWarning, PiratesGuiGlobals.TextFG6)
             return None
         
         areaList = self.getAreaList(skillId, ammoSkillId, ship, pos, attackerId)
         result = self.cr.battleMgr.doAttack(attacker, skillId, ammoSkillId, shipId, areaList, pos)
         self.sendSuggestProjectileSkillResult(skillId, ammoSkillId, result, shipId, areaList, [
             pos[0],
             pos[1],
             pos[2]], [
             normal[0],
             normal[1],
             normal[2]], codes, timestamp32)
         effectList = [
             shipId] + areaList
         propId = hitObject.getNetTag('propId')
         if propId:
             propId = int(propId)
             effectList += [
                 propId]
             prop = self.cr.doId2do.get(propId)
             if prop:
                 result = self.cr.battleMgr.doAttack(attacker, skillId, ammoSkillId, propId, [], pos)
                 self.sendSuggestProjectileSkillResult(skillId, ammoSkillId, result, propId, [], [
                     pos[0],
                     pos[1],
                     pos[2]], [
                     normal[0],
                     normal[1],
                     normal[2]], codes, timestamp32)
             
         
         for doId in effectList:
             target = self.cr.doId2do.get(doId)
             if target:
                 (attackerEffects, targetEffects, itemEffects) = self.cr.battleMgr.getModifiedSkillEffects(attacker, target, skillId, ammoSkillId)
                 target.projectileWeaponHit(skillId, ammoSkillId, result, targetEffects, pos, normal, codes, attacker, itemEffects)
                 continue
示例#17
0
 def d_setAnimState(self, anim):
     timestamp = globalClockDelta.getFrameNetworkTime()
     self.sendUpdate('setAnimState', [anim, timestamp])
示例#18
0
 def d_setAnimState(self, anim):
     if type(anim) == types.StringType:
         anim = self.animState2animId[anim]
     timestamp = globalClockDelta.getFrameNetworkTime()
     self.sendUpdate('setAnimState', [anim, timestamp])
 def b_rewardSequenceComplete(self):
     timestamp = globalClockDelta.getFrameNetworkTime()
     self.rewardSequenceComplete(timestamp)
     self.d_rewardSequenceComplete(timestamp)
示例#20
0
 def d_gunShot(self):
     timestamp = globalClockDelta.getFrameNetworkTime()
     self.sendUpdate('gunShot', [base.localAvatar.doId, timestamp])
示例#21
0
 def d_setSuitState(self, index, startPoint, endPoint):
     self.stateTimestamp = globalClockDelta.getFrameNetworkTime()
     self.sendUpdate('setSuitState',
                     [index, startPoint, endPoint, self.stateTimestamp])
 def d_sendPitcherPos(self):
     timestamp = globalClockDelta.getFrameNetworkTime()
     self.sendUpdate(
         'setPitcherPos',
         [self.changeSeq,
          self.waterPitcherNode.getH(), timestamp])
 def d_sendGolfSpotPos(self):
     timestamp = globalClockDelta.getFrameNetworkTime()
     self.sendUpdate('setGolfSpotPos', [self.changeSeq, self.root.getH(), timestamp])
示例#24
0
 def startScanning(self, afterShoot=0):
     if not self.isDead():
         timestamp = globalClockDelta.getFrameNetworkTime()
         self.sendUpdate('scan', [timestamp, afterShoot])
         base.taskMgr.add(self.__scan,
                          self.uniqueName('DistributedPieTurretAI-scan'))
 def _WeaponBase__propHit(self, shipId, propId, hitObject, entry, skillId, ammoSkillId):
     cannonCode = 0
     cannonCodeStr = hitObject.getNetTag('cannonCode')
     if cannonCodeStr:
         cannonCode = int(cannonCodeStr)
     
     hullCode = 0
     hullCodeStr = hitObject.getNetTag('hullCode')
     if hullCodeStr:
         hullCode = int(hullCodeStr)
     
     sailCode = 0
     sailCodeStr = hitObject.getNetTag('sailCode')
     if sailCodeStr:
         sailCode = int(sailCodeStr)
     
     codes = [
         cannonCode,
         hullCode,
         sailCode]
     ship = self.cr.doId2do.get(shipId)
     prop = self.cr.doId2do.get(propId)
     if not ship or ship.queryGameState() == 'Inactive':
         return None
     
     if not prop:
         return None
     
     if self.localAvatarUsingWeapon:
         pos = entry.getSurfacePoint(ship)
         normal = entry.getSurfaceNormal(render)
         timestamp32 = globalClockDelta.getFrameNetworkTime(bits = 32)
         attackerId = 0
         attackerStr = entry.getFromNodePath().getNetTag('attackerId')
         if attackerStr:
             attackerId = int(attackerStr)
         
         attacker = self.cr.doId2do.get(attackerId)
         if not attacker:
             return None
         
         if not TeamUtils.damageAllowed(attacker, prop) and not TeamUtils.damageAllowed(attacker, ship):
             if hasattr(attacker, 'getName') and hasattr(prop, 'getName'):
                 if TeamUtils.friendOrFoe(attacker, ship) == PiratesGlobals.PVP_FRIEND:
                     localAvatar.guiMgr.createWarning(PLocalizer.TeamFireWarning, PiratesGuiGlobals.TextFG6)
                 else:
                     localAvatar.guiMgr.createWarning(PLocalizer.FriendlyFireWarning, PiratesGuiGlobals.TextFG6)
             
             attacker.battleRandom.advanceAttackSeed()
             return None
         
         areaList = self.getAreaList(skillId, ammoSkillId, ship, pos, attackerId)
         result = self.cr.battleMgr.doAttack(attacker, skillId, ammoSkillId, propId, areaList, pos)
         self.sendSuggestProjectileSkillResult(skillId, ammoSkillId, result, propId, areaList, [
             pos[0],
             pos[1],
             pos[2]], [
             normal[0],
             normal[1],
             normal[2]], codes, timestamp32)
         for doId in [
             propId] + areaList:
             target = self.cr.doId2do.get(doId)
             (attackerEffects, targetEffects, itemEffects) = self.cr.battleMgr.getModifiedSkillEffects(attacker, target, skillId, ammoSkillId)
             target.projectileWeaponHit(skillId, ammoSkillId, result, targetEffects, pos, normal, codes, attacker, itemEffects)
    def _WeaponBase__shippartHit(self, hitObject, entry, skillId, ammoSkillId):
        shipId = hitObject.getNetTag("shipId")
        if shipId:
            shipId = int(shipId)
            ship = base.cr.doId2do.get(shipId)
            if ship:
                if ship.queryGameState() in ("FadeOut", "Sinking", "Inactive"):
                    return None

            else:
                return None
            fromNodePath = entry.getFromNodePath()
            attackerShipId = fromNodePath.getNetTag("shipId")
            if attackerShipId:
                attackerShipId = int(attackerShipId)
                if attackerShipId == shipId:
                    return None

            attackerId = 0
            attackerStr = entry.getFromNodePath().getNetTag("attackerId")
            if attackerStr:
                attackerId = int(attackerStr)
                attacker = self.cr.doId2do.get(attackerId)
                if not attacker:
                    return None

            else:
                return None
            cannonCode = 0
            cannonCodeStr = hitObject.getNetTag("cannonCode")
            if cannonCodeStr:
                cannonCode = int(cannonCodeStr)

            hullCode = 0
            hullCodeStr = hitObject.getNetTag("hullCode")
            if hullCodeStr:
                hullCode = int(hullCodeStr)

            sailCode = 0
            sailCodeStr = hitObject.getNetTag("sailCode")
            if sailCodeStr:
                sailCode = int(sailCodeStr)

            codes = [cannonCode, hullCode, sailCode]
            pos = entry.getSurfacePoint(ship)
            normal = entry.getSurfaceNormal(render)
            timestamp32 = globalClockDelta.getFrameNetworkTime(bits=32)
            if not TeamUtils.damageAllowed(attacker, ship):
                if TeamUtils.friendOrFoe(attacker, ship) == PiratesGlobals.PVP_FRIEND:
                    localAvatar.guiMgr.createWarning(PLocalizer.TeamFireWarning, PiratesGuiGlobals.TextFG6)
                else:
                    localAvatar.guiMgr.createWarning(PLocalizer.FriendlyFireWarning, PiratesGuiGlobals.TextFG6)
                return None

            areaList = self.getAreaList(skillId, ammoSkillId, ship, pos, attackerId)
            result = self.cr.battleMgr.doAttack(attacker, skillId, ammoSkillId, shipId, areaList, pos)
            self.sendSuggestProjectileSkillResult(
                skillId,
                ammoSkillId,
                result,
                shipId,
                areaList,
                [pos[0], pos[1], pos[2]],
                [normal[0], normal[1], normal[2]],
                codes,
                timestamp32,
            )
            effectList = [shipId] + areaList
            propId = hitObject.getNetTag("propId")
            if propId:
                propId = int(propId)
                effectList += [propId]
                prop = self.cr.doId2do.get(propId)
                if prop:
                    result = self.cr.battleMgr.doAttack(attacker, skillId, ammoSkillId, propId, [], pos)
                    self.sendSuggestProjectileSkillResult(
                        skillId,
                        ammoSkillId,
                        result,
                        propId,
                        [],
                        [pos[0], pos[1], pos[2]],
                        [normal[0], normal[1], normal[2]],
                        codes,
                        timestamp32,
                    )

            for doId in effectList:
                target = self.cr.doId2do.get(doId)
                if target:
                    (attackerEffects, targetEffects, itemEffects) = self.cr.battleMgr.getModifiedSkillEffects(
                        attacker, target, skillId, ammoSkillId
                    )
                    target.projectileWeaponHit(
                        skillId, ammoSkillId, result, targetEffects, pos, normal, codes, attacker, itemEffects
                    )
                    continue
    def _WeaponBase__propHit(self, shipId, propId, hitObject, entry, skillId, ammoSkillId):
        cannonCode = 0
        cannonCodeStr = hitObject.getNetTag("cannonCode")
        if cannonCodeStr:
            cannonCode = int(cannonCodeStr)

        hullCode = 0
        hullCodeStr = hitObject.getNetTag("hullCode")
        if hullCodeStr:
            hullCode = int(hullCodeStr)

        sailCode = 0
        sailCodeStr = hitObject.getNetTag("sailCode")
        if sailCodeStr:
            sailCode = int(sailCodeStr)

        codes = [cannonCode, hullCode, sailCode]
        ship = self.cr.doId2do.get(shipId)
        prop = self.cr.doId2do.get(propId)
        if not ship or ship.queryGameState() == "Inactive":
            return None

        if not prop:
            return None

        if self.localAvatarUsingWeapon:
            pos = entry.getSurfacePoint(ship)
            normal = entry.getSurfaceNormal(render)
            timestamp32 = globalClockDelta.getFrameNetworkTime(bits=32)
            attackerId = 0
            attackerStr = entry.getFromNodePath().getNetTag("attackerId")
            if attackerStr:
                attackerId = int(attackerStr)

            attacker = self.cr.doId2do.get(attackerId)
            if not attacker:
                return None

            if not TeamUtils.damageAllowed(attacker, prop) and not TeamUtils.damageAllowed(attacker, ship):
                if hasattr(attacker, "getName") and hasattr(prop, "getName"):
                    if TeamUtils.friendOrFoe(attacker, ship) == PiratesGlobals.PVP_FRIEND:
                        localAvatar.guiMgr.createWarning(PLocalizer.TeamFireWarning, PiratesGuiGlobals.TextFG6)
                    else:
                        localAvatar.guiMgr.createWarning(PLocalizer.FriendlyFireWarning, PiratesGuiGlobals.TextFG6)

                attacker.battleRandom.advanceAttackSeed()
                return None

            areaList = self.getAreaList(skillId, ammoSkillId, ship, pos, attackerId)
            result = self.cr.battleMgr.doAttack(attacker, skillId, ammoSkillId, propId, areaList, pos)
            self.sendSuggestProjectileSkillResult(
                skillId,
                ammoSkillId,
                result,
                propId,
                areaList,
                [pos[0], pos[1], pos[2]],
                [normal[0], normal[1], normal[2]],
                codes,
                timestamp32,
            )
            for doId in [propId] + areaList:
                target = self.cr.doId2do.get(doId)
                (attackerEffects, targetEffects, itemEffects) = self.cr.battleMgr.getModifiedSkillEffects(
                    attacker, target, skillId, ammoSkillId
                )
                target.projectileWeaponHit(
                    skillId, ammoSkillId, result, targetEffects, pos, normal, codes, attacker, itemEffects
                )
 def d_sendPitcherPos(self):
     timestamp = globalClockDelta.getFrameNetworkTime()
     self.sendUpdate("setPitcherPos", [self.changeSeq, self.waterPitcherNode.getH(), timestamp])
示例#29
0
    def requestJoke(self):
        avId = self.air.getAvatarIdFromSender()

        timestamp = globalClockDelta.getFrameNetworkTime()
        self.listenerId = avId
        self.sendUpdate('playJoke', [avId, timestamp])
示例#30
0
 def startScanning(self, afterShoot=0):
     if self.getHealth() > 0:
         timestamp = globalClockDelta.getFrameNetworkTime()
         self.sendUpdate("scan", [timestamp, afterShoot])
         base.taskMgr.add(self.__scan, self.uniqueName("DistributedPieTurretAI-scan"))
示例#31
0
 def setAnimStates(self, animName, animMultiplier=1.0, timestamp=None, animType=None, callback=None, extraArgs=[]):
     timestamp = globalClockDelta.getFrameNetworkTime()
     #self.sendUpdate('setAnimStates', args=[str(animName), animMultiplier, timestamp])
     self.animState = animName
示例#32
0
 def d_setAnimStates(self, animName, animMultiplier=1.0, timestamp=None, extraArgs=[]):
     timestamp = globalClockDelta.getFrameNetworkTime()
     self.sendUpdate('setAnimStates', args=['victory', 1.0, timestamp])
示例#33
0
 def d_setAnimState(self, animName, animMultiplier=1.0, timestamp=None, extraArgs=[]):
     if self.animFSM.getCurrentState().getName() == animName:
         return None
     timestamp = globalClockDelta.getFrameNetworkTime()
     print 'here'
     self.sendUpdate('setAnimState', [animName, animMultiplier, timestamp])
 def simpleShipHit(self, hitObject, entry, skillId, ammoSkillId):
     timestamp32 = globalClockDelta.getFrameNetworkTime(bits = 32)
     ship = hitObject.getNetPythonTag('ship')
     if not ship:
         self.notify.warning('ignoring attack on destroyed ship')
         return None
     
     attackerShipId = entry.getFromNodePath().getNetTag('shipId')
     hullCode = hitObject.getNetTag('Hull Code')
     if hullCode:
         hullCode = int(hullCode)
     else:
         hullCode = 255
     mastCode = hitObject.getNetTag('Mast Code')
     hitSail = hitObject.getNetTag('Sail')
     if not hitSail:
         hitSail = 0
     else:
         hitSail = 1
     if mastCode:
         mastCode = int(mastCode)
     else:
         mastCode = 255
     pos = entry.getSurfacePoint(ship)
     normal = entry.getSurfaceNormal(render)
     attackerId = 0
     attackerStr = entry.getFromNodePath().getNetTag('attackerId')
     if attackerStr:
         attackerId = int(attackerStr)
     
     attacker = self.cr.doId2do.get(attackerId)
     if not attacker:
         return None
     
     if attackerShipId:
         if int(attackerShipId) == ship.doId:
             return None
         
     
     if not TeamUtils.damageAllowed(attacker, ship):
         if TeamUtils.friendOrFoe(attacker, ship) == PiratesGlobals.PVP_FRIEND:
             localAvatar.guiMgr.createWarning(PLocalizer.TeamFireWarning, PiratesGuiGlobals.TextFG6)
         else:
             localAvatar.guiMgr.createWarning(PLocalizer.FriendlyFireWarning, PiratesGuiGlobals.TextFG6)
         attacker.battleRandom.advanceAttackSeed()
         return None
     
     if ship:
         ship.validateMastCode(mastCode)
     
     result = self.cr.battleMgr.doAttack(attacker, skillId, ammoSkillId, ship.doId, [], pos)
     ammo = entry.getFromNodePath().getNetPythonTag('ammo')
     if ammo:
         if ammo.hasTag('newAmmoId'):
             ammoSkillId = int(ammo.getTag('newAmmoId'))
             pos = (0, 0, 0)
         
     
     self.sendSuggestProjectileSkillResult(skillId, ammoSkillId, result, ship.doId, [], [
         pos[0],
         pos[1],
         pos[2]], [
         normal[0],
         normal[1],
         normal[2]], [
         hullCode,
         mastCode,
         hitSail], timestamp32)
     (attackerEffects, targetEffects, itemEffects) = self.cr.battleMgr.getModifiedSkillEffects(attacker, ship, skillId, ammoSkillId)
     ship.projectileWeaponHit(skillId, ammoSkillId, result, targetEffects, pos, normal, (hullCode, mastCode, hitSail), attacker, itemEffects)
     return True
示例#35
0
 def d_setSuitState(self, index, startPoint, endPoint):
     self.stateTimestamp = globalClockDelta.getFrameNetworkTime()
     self.sendUpdate('setSuitState', [index,
      startPoint,
      endPoint,
      self.stateTimestamp])
示例#36
0
 def d_setAnimState(self, anim):
     timestamp = globalClockDelta.getFrameNetworkTime()
     self.sendUpdate('setAnimState', [anim, timestamp])
 def d_sendGolfSpotPos(self):
     timestamp = globalClockDelta.getFrameNetworkTime()
     self.sendUpdate('setGolfSpotPos', [self.changeSeq, self.root.getH(), timestamp])
 def d_setState(self, state):
     self.stateTimestamp = globalClockDelta.getFrameNetworkTime()
     self.sendUpdate('setState', [state, self.stateTimestamp])
示例#39
0
 def d_setAnimState(self, anim):
     if type(anim) == types.StringType:
         anim = self.animState2animId[anim]
     timestamp = globalClockDelta.getFrameNetworkTime()
     self.sendUpdate('setAnimState', [anim, timestamp])
 def d_startCircleAnim(self, direction):
     if direction == 1:
         self.elapsedCaptureResetTime = 0
         self.elapsedCaptureTime = 0
     timestamp = globalClockDelta.getFrameNetworkTime()
     self.sendUpdate('startCircleAnim', [direction, timestamp])