def _DistributedShipBroadside__requestAttack(self, index, side, targetPos, flightTime):
     if side == 0:
         if self.leftBroadside and self.leftBroadsideConfig:
             cannonList = self.leftBroadside
             cannonConfig = self.leftBroadsideConfig
         
         skillId = EnemySkills.LEFT_BROADSIDE
     elif side == 1:
         if self.rightBroadside and self.rightBroadsideConfig:
             cannonList = self.rightBroadside
             cannonConfig = self.rightBroadsideConfig
         
         skillId = EnemySkills.RIGHT_BROADSIDE
     
     ammoSkillId = self.ammoType
     if cannonList and cannonConfig:
         cannonList[index].playFire()
         cballSpawnPoint = cannonList[index].locator
         cballSpawnPoint.setP(render, 0)
         self.playFireEffect(cballSpawnPoint, ammoSkillId)
         if not WeaponGlobals.isProjectileSkill(skillId, ammoSkillId):
             return None
         
         pos = cballSpawnPoint.getPos(render) + Vec3(0, -25, 0)
         if targetPos:
             self.playAttack(skillId, ammoSkillId, pos, targetPos = targetPos, flightTime = flightTime)
         else:
             m = cballSpawnPoint.getMat(self)
             power = WeaponGlobals.getAttackProjectilePower(ammoSkillId) * CannonGlobals.BROADSIDE_POWERMOD
             if side == 1:
                 startVel = m.xformVec(Vec3(0, -power, 90))
             else:
                 startVel = m.xformVec(Vec3(0, -power, 90))
             self.playAttack(skillId, ammoSkillId, pos, startVel)
 def __requestAttack(self, index, side, targetPos, flightTime, fireSecondary=False):
     if side == 0:
         if self.leftBroadside:
             if self.leftBroadsideConfig:
                 cannonList = self.leftBroadside
                 cannonConfig = self.leftBroadsideConfig
             skillId = EnemySkills.LEFT_BROADSIDE
         else:
             if side == 1:
                 if (self.rightBroadside and self).rightBroadsideConfig:
                     cannonList = self.rightBroadside
                     cannonConfig = self.rightBroadsideConfig
                 skillId = EnemySkills.RIGHT_BROADSIDE
         ammoSkillId = self.ammoType
         if fireSecondary:
             ammoSkillId = self.secondaryAmmoType
         if cannonList:
             cannonConfig and cannonList[index].playFire()
             cballSpawnPoint = cannonList[index].locator
             cballSpawnPoint.setP(render, 0)
             self.playFireEffect(cballSpawnPoint, ammoSkillId)
             if not WeaponGlobals.isProjectileSkill(skillId, ammoSkillId):
                 return
             pos = cballSpawnPoint.getPos(render) + Vec3(0, -25, 0)
             targetPos and self.playAttack(skillId, ammoSkillId, pos, targetPos=targetPos, flightTime=flightTime)
         else:
             m = cballSpawnPoint.getMat(self)
             power = WeaponGlobals.getAttackProjectilePower(ammoSkillId) * CannonGlobals.BROADSIDE_POWERMOD
             if side == 1:
                 startVel = m.xformVec(Vec3(0, -power, 90))
             else:
                 startVel = m.xformVec(Vec3(0, -power, 90))
             self.playAttack(skillId, ammoSkillId, pos, startVel)
 def playAttack(self, skillId, ammoSkillId, pos = 0, startVel = 0, targetPos = None, flightTime = 0):
     if not WeaponGlobals.isProjectileSkill(skillId, ammoSkillId):
         if self.localAvatarUsingWeapon:
             localAvatar.composeRequestTargetedSkill(skillId, ammoSkillId)
         
         return None
     
     self.ammoSequence = self.ammoSequence + 1 & 255
     buffs = []
     if self.av:
         buffs = self.av.getSkillEffects()
     
     ammo = self.getProjectile(ammoSkillId, self.projectileHitEvent, buffs)
     ammo.setPos(pos)
     if skillId == EnemySkills.LEFT_BROADSIDE:
         ammo.setH(render, self.ship.getH(render) + 90)
     elif skillId == EnemySkills.RIGHT_BROADSIDE:
         ammo.setH(render, self.ship.getH(render) - 90)
     
     collNode = ammo.getCollNode()
     collNode.reparentTo(render)
     ammo.setTag('ammoSequence', str(self.ammoSequence))
     ammo.setTag('skillId', str(int(skillId)))
     ammo.setTag('ammoSkillId', str(int(ammoSkillId)))
     if self.av:
         ammo.setTag('attackerId', str(self.av.doId))
     
     startPos = pos
     endPlaneZ = -10
     if self.ship:
         ammo.setTag('shipId', str(self.ship.doId))
         self.shotNum += 1
         if self.shotNum > 100000:
             self.shotNum = 0
         
         ammo.setTag('shotNum', str(self.shotNum))
         self.baseVel = self.ship.worldVelocity
     
     if startPos[2] < endPlaneZ:
         self.notify.warning('bad startPos Z: %s' % startPos[2])
         return None
     
     if targetPos is None:
         startVel += self.baseVel
         pi = ProjectileInterval(ammo, startPos = startPos, startVel = startVel, endZ = endPlaneZ, gravityMult = 2.0, collNode = collNode)
     elif self.ship.getNPCship():
         pi = ProjectileInterval(ammo, endZ = endPlaneZ, startPos = startPos, wayPoint = targetPos, timeToWayPoint = flightTime, gravityMult = 0.5, collNode = collNode)
     else:
         pi = ProjectileInterval(ammo, endZ = endPlaneZ, startPos = startPos, wayPoint = targetPos, timeToWayPoint = flightTime, gravityMult = 1.2, collNode = collNode)
     if base.cr.cannonballCollisionDebug == 1 or base.cr.cannonballCollisionDebug == 2:
         addFunc = Func(base.cTrav.addCollider, collNode, ammo.collHandler)
         delFunc = Func(base.cTrav.removeCollider, collNode)
     else:
         addFunc = Wait(0)
         delFunc = Wait(0)
     s = Parallel(Sequence(Wait(0.10000000000000001), addFunc), Sequence(pi, Func(ammo.destroy), delFunc))
     ammo.setIval(s, start = True)
Exemple #4
0
 def playAttack(self, skillId, ammoSkillId, pos = 0, startVel = 0, targetPos = None, flightTime = 0):
     if not WeaponGlobals.isProjectileSkill(skillId, ammoSkillId):
         if self.localAvatarUsingWeapon:
             localAvatar.composeRequestTargetedSkill(skillId, ammoSkillId)
         
         return None
     
     self.ammoSequence = self.ammoSequence + 1 & 255
     buffs = []
     if self.av:
         buffs = self.av.getSkillEffects()
     
     ammo = self.getProjectile(ammoSkillId, self.projectileHitEvent, buffs)
     ammo.setPos(pos)
     if skillId == EnemySkills.LEFT_BROADSIDE:
         ammo.setH(render, self.ship.getH(render) + 90)
     elif skillId == EnemySkills.RIGHT_BROADSIDE:
         ammo.setH(render, self.ship.getH(render) - 90)
     
     collNode = ammo.getCollNode()
     collNode.reparentTo(render)
     ammo.setTag('ammoSequence', str(self.ammoSequence))
     ammo.setTag('skillId', str(int(skillId)))
     ammo.setTag('ammoSkillId', str(int(ammoSkillId)))
     if self.av:
         ammo.setTag('attackerId', str(self.av.doId))
     
     startPos = pos
     endPlaneZ = -10
     if self.ship:
         ammo.setTag('shipId', str(self.ship.doId))
         self.shotNum += 1
         if self.shotNum > 100000:
             self.shotNum = 0
         
         ammo.setTag('shotNum', str(self.shotNum))
         self.baseVel = self.ship.worldVelocity
     
     if startPos[2] < endPlaneZ:
         self.notify.warning('bad startPos Z: %s' % startPos[2])
         return None
     
     if targetPos is None:
         startVel += self.baseVel
         pi = ProjectileInterval(ammo, startPos = startPos, startVel = startVel, endZ = endPlaneZ, gravityMult = 2.0, collNode = collNode)
     elif self.ship.getNPCship():
         pi = ProjectileInterval(ammo, endZ = endPlaneZ, startPos = startPos, wayPoint = targetPos, timeToWayPoint = flightTime, gravityMult = 0.5, collNode = collNode)
     else:
         pi = ProjectileInterval(ammo, endZ = endPlaneZ, startPos = startPos, wayPoint = targetPos, timeToWayPoint = flightTime, gravityMult = 1.2, collNode = collNode)
     if base.cr.cannonballCollisionDebug == 1 or base.cr.cannonballCollisionDebug == 2:
         addFunc = Func(base.cTrav.addCollider, collNode, ammo.collHandler)
         delFunc = Func(base.cTrav.removeCollider, collNode)
     else:
         addFunc = Wait(0)
         delFunc = Wait(0)
     s = Parallel(Sequence(Wait(0.10000000000000001), addFunc), Sequence(pi, Func(ammo.destroy), delFunc))
     ammo.setIval(s, start = True)