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, projectileHitEvent, targetPos = None, wantCollisions = 0, flightTime = None, preciseHit = False, buffs = [], timestamp = None, numShots = 1, shotNum = -1): if base.cr.wantSpecialEffects != 0: self.playFireEffect(ammoSkillId, buffs) if ammoSkillId == InventoryType.CannonGrapeShot: numShots = 7 disperseAmount = (35, 0.0) else: disperseAmount = (40, 20.0) wantCollisions = 1 self.ammoSequence = self.ammoSequence + 1 & 255 if ammoSkillId in (InventoryType.DefenseCannonScatterShot, InventoryType.CannonGrapeShot): scatterOffset = random.uniform(0, 360) for i in range(numShots): ammo = self.getProjectile(ammoSkillId, projectileHitEvent, buffs) collNode = None if self.localAvatarUsingWeapon or wantCollisions: collNode = ammo.getCollNode() collNode.reparentTo(render) if shotNum > -1: self.shotNum = shotNum else: self.shotNum += 1 if self.shotNum > 100000: self.shotNum = 0 ammo.setTag('shotNum', str(self.shotNum)) 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)) if hasattr(self, 'fortId'): ammo.setTag('fortId', str(self.fortId)) if hasattr(self, 'ship') and self.ship and hasattr(self.ship, 'doId'): setShipTag = True if setShipTag: ammo.setTag('shipId', str(self.ship.doId)) startPos = self.cannonExitPoint.getPos(render) ammo.setPos(startPos) ammo.setH(self.hNode.getH(render)) ammo.setP(self.pivot.getP(render)) endPlaneZ = -100 if startPos[2] < endPlaneZ: self.notify.warning('bad startPos Z: %s' % startPos[2]) return None m = ammo.getMat(render) curPower = WeaponGlobals.getAttackProjectilePower(skillId, ammoSkillId) * 0.59999999999999998 if targetPos is None: if ammoSkillId in (InventoryType.DefenseCannonScatterShot, InventoryType.CannonGrapeShot) and i > 0: dist = Vec3(math.fabs(random.gauss(0, disperseAmount[0])) + disperseAmount[1], curPower, 0.0) angle = Mat3.rotateMatNormaxis(random.uniform(0, 360 / numShots) + i * 360 / (numShots - 1) + scatterOffset, Vec3.forward()) dist = angle.xform(dist) startVel = m.xformVec(dist) else: startVel = m.xformVec(Vec3(0, curPower, 0)) if self.ship: fvel = self.ship.smoother.getSmoothForwardVelocity() * 0.5 faxis = self.ship.smoother.getForwardAxis() self.baseVel = faxis * fvel startVel += self.baseVel else: startVel = m.xformVec(Vec3(0, 20, 2)) def attachRope(): if ammoSkillId == InventoryType.CannonGrappleHook and self.cannonPost: rope = self.getRope() rope.reparentTo(ammo) rope.setup(3, ((None, Point3(0, 0, 0)), (self.cannonPost, Point3(2, 5, 10)), (self.cannonPost, Point3(2, 0, 0)))) if preciseHit: if flightTime is None: flightTime = CannonGlobals.AI_FIRE_TIME pi = ProjectileInterval(ammo, startPos = startPos, endPos = targetPos, duration = flightTime, collNode = collNode) elif targetPos: if flightTime is None: flightTime = CannonGlobals.getCannonballFlightTime(startPos, targetPos, curPower) pi = ProjectileInterval(ammo, endZ = endPlaneZ, startPos = startPos, wayPoint = targetPos, timeToWayPoint = flightTime, gravityMult = 2.5, collNode = collNode) else: pi = ProjectileInterval(ammo, startPos = startPos, startVel = startVel, endZ = endPlaneZ, gravityMult = 4.0, collNode = collNode) if self.localAvatarUsingWeapon or wantCollisions: if base.cr.cannonballCollisionDebug == 1 or base.cr.cannonballCollisionDebug == 3: addFunc = Func(base.cTrav.addCollider, collNode, ammo.collHandler) delFunc = Func(base.cTrav.removeCollider, collNode) else: addFunc = Wait(0) delFunc = Wait(0) s = Sequence(addFunc, Func(attachRope), pi, Func(ammo.destroy), delFunc) else: s = Sequence(Func(attachRope), pi, Func(ammo.destroy)) ts = 0 if timestamp: ts = globalClockDelta.localElapsedTime(timestamp) ammo.setIval(s, start = True, offset = ts)
def playAttack(self, skillId, ammoSkillId, projectileHitEvent, targetPos = None, wantCollisions = 0, flightTime = None, preciseHit = False, buffs = [], timestamp = None, numShots = 1, shotNum = -1): if base.cr.wantSpecialEffects != 0: self.playFireEffect(ammoSkillId, buffs) if ammoSkillId == InventoryType.CannonGrapeShot: numShots = 7 disperseAmount = (35, 0.0) else: disperseAmount = (40, 20.0) wantCollisions = 1 self.ammoSequence = self.ammoSequence + 1 & 255 if ammoSkillId in (InventoryType.DefenseCannonScatterShot, InventoryType.CannonGrapeShot): scatterOffset = random.uniform(0, 360) for i in range(numShots): ammo = self.getProjectile(ammoSkillId, projectileHitEvent, buffs) collNode = None if self.localAvatarUsingWeapon or wantCollisions: collNode = ammo.getCollNode() collNode.reparentTo(render) if shotNum > -1: self.shotNum = shotNum else: self.shotNum += 1 if self.shotNum > 100000: self.shotNum = 0 ammo.setTag('shotNum', str(self.shotNum)) 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)) if hasattr(self, 'fortId'): ammo.setTag('fortId', str(self.fortId)) if hasattr(self, 'ship') and self.ship and hasattr(self.ship, 'doId'): setShipTag = True if setShipTag: ammo.setTag('shipId', str(self.ship.doId)) startPos = self.cannonExitPoint.getPos(render) ammo.setPos(startPos) ammo.setH(self.hNode.getH(render)) ammo.setP(self.pivot.getP(render)) endPlaneZ = -100 if startPos[2] < endPlaneZ: self.notify.warning('bad startPos Z: %s' % startPos[2]) return None m = ammo.getMat(render) curPower = WeaponGlobals.getAttackProjectilePower(skillId, ammoSkillId) * 0.59999999999999998 if targetPos is None: if ammoSkillId in (InventoryType.DefenseCannonScatterShot, InventoryType.CannonGrapeShot) and i > 0: dist = Vec3(math.fabs(random.gauss(0, disperseAmount[0])) + disperseAmount[1], curPower, 0.0) angle = Mat3.rotateMatNormaxis(random.uniform(0, 360 / numShots) + i * 360 / (numShots - 1) + scatterOffset, Vec3.forward()) dist = angle.xform(dist) startVel = m.xformVec(dist) else: startVel = m.xformVec(Vec3(0, curPower, 0)) if self.ship: fvel = self.ship.smoother.getSmoothForwardVelocity() * 0.5 faxis = self.ship.smoother.getForwardAxis() self.baseVel = faxis * fvel startVel += self.baseVel else: startVel = m.xformVec(Vec3(0, 20, 2)) def attachRope(): if ammoSkillId == InventoryType.CannonGrappleHook and self.cannonPost: rope = self.getRope() rope.reparentTo(ammo) rope.setup(3, ((None, Point3(0, 0, 0)), (self.cannonPost, Point3(2, 5, 10)), (self.cannonPost, Point3(2, 0, 0)))) if preciseHit: if flightTime is None: flightTime = CannonGlobals.AI_FIRE_TIME pi = ProjectileInterval(ammo, startPos = startPos, endPos = targetPos, duration = flightTime, collNode = collNode) elif targetPos: if flightTime is None: flightTime = CannonGlobals.getCannonballFlightTime(startPos, targetPos, curPower) pi = ProjectileInterval(ammo, endZ = endPlaneZ, startPos = startPos, wayPoint = targetPos, timeToWayPoint = flightTime, gravityMult = 2.5, collNode = collNode) else: pi = ProjectileInterval(ammo, startPos = startPos, startVel = startVel, endZ = endPlaneZ, gravityMult = 4.0, collNode = collNode) if self.localAvatarUsingWeapon or wantCollisions: if base.cr.cannonballCollisionDebug == 1 or base.cr.cannonballCollisionDebug == 3: addFunc = Func(base.cTrav.addCollider, collNode, ammo.collHandler) delFunc = Func(base.cTrav.removeCollider, collNode) else: addFunc = Wait(0) delFunc = Wait(0) s = Sequence(addFunc, Func(attachRope), pi, Func(ammo.destroy), delFunc) else: s = Sequence(Func(attachRope), pi, Func(ammo.destroy)) ts = 0 if timestamp: ts = globalClockDelta.localElapsedTime(timestamp) ammo.setIval(s, start = True, offset = ts)