def loadVirtualSuit(self): dna = SuitDNA.SuitDNA() dna.newSuit(self.getSuitName()) self.virtualSuit = Suit.Suit() self.virtualSuit.reparentTo(self) self.virtualSuit.setDNA(dna) self.virtualSuit.setPos(self, 0.0, 2.5, 0.0) self.virtualSuit.makeSkeleton(wantNameInfo=False) self.virtualSuit.makeVirtual() self.virtualSuit.hideName() anims = self.generateSuitAnimDict() self.virtualSuit.loadAnims(anims) self.virtualSuit.loop('walk', 0) synergyBox = CollisionBox(0, 3.5, 10, 1) synergyBox.setTangible(0) synergyNode = CollisionNode(self.uniqueName('SynergyAttack')) synergyNode.setTag('damage', '10') synergyNode.addSolid(synergyBox) synergyNode.setIntoCollideMask(WallBitmask) self.synergyColl = self.virtualSuit.attachNewNode(synergyNode) self.synergyColl.setPos(0.0, 9.0, 0.0) self.synergyColl.stash() self.synergySfx = loader.loadSfx('phase_5/audio/sfx/SA_synergy.ogg') self.teeOffSfx = loader.loadSfx('phase_5/audio/sfx/SA_tee_off.ogg') self.writeOffSfx = loader.loadSfx( 'phase_5/audio/sfx/SA_writeoff_pen_only.ogg') self.dingSfx = loader.loadSfx( 'phase_5/audio/sfx/SA_writeoff_ding_only.ogg')
def loadVirtualSuit(self): dna = SuitDNA.SuitDNA() dna.newSuit(self.getSuitName()) self.virtualSuit = Suit.Suit() self.virtualSuit.reparentTo(self) self.virtualSuit.setDNA(dna) self.virtualSuit.setPos(self, 0.0, 2.5, 0.0) self.virtualSuit.makeSkeleton(wantNameInfo=False) self.virtualSuit.makeVirtual() self.virtualSuit.hideName() anims = self.generateSuitAnimDict() self.virtualSuit.loadAnims(anims) self.virtualSuit.loop('walk', 0) synergyBox = CollisionBox(0, 3.5, 10, 1) synergyBox.setTangible(0) synergyNode = CollisionNode(self.uniqueName('SynergyAttack')) synergyNode.setTag('damage', '10') synergyNode.addSolid(synergyBox) synergyNode.setIntoCollideMask(WallBitmask) self.synergyColl = self.virtualSuit.attachNewNode(synergyNode) self.synergyColl.setPos(0.0, 9.0, 0.0) self.synergyColl.stash() self.synergySfx = loader.loadSfx('phase_5/audio/sfx/SA_synergy.ogg') self.teeOffSfx = loader.loadSfx('phase_5/audio/sfx/SA_tee_off.ogg') self.writeOffSfx = loader.loadSfx('phase_5/audio/sfx/SA_writeoff_pen_only.ogg') self.dingSfx = loader.loadSfx('phase_5/audio/sfx/SA_writeoff_ding_only.ogg')
class Bullet(NodePath): def __init__(self, x, y, z, direction, id): NodePath.__init__(self,loader.loadModel("../Models/missile")) self.reparentTo(render) self.setPos(x, y, z) self.direction = Vec3() self.direction.set(direction.getX(), direction.getY(), direction.getZ()) self.setH(Vec2.signedAngleDeg(Vec2(0,1), Vec2(direction.getX(),direction.getY()))) if self.direction.length() == 0: self.removeNode() return self.direction /= direction.length() min, max = self.getTightBounds() size = max - min maximum = -1 for i in size: if i > maximum: maximum = i self.cnode = CollisionNode('bullet') self.cnode.setTag( "id", str(id) ) self.cnode.addSolid(CollisionSphere(0, 0, 0, maximum + 0.3)) self.cnodePath = self.attachNewNode(self.cnode) self.cnodePath.show() base.cTrav.addCollider(self.cnodePath, base.event) taskMgr.add(self.updateBullet, "update Bullet") print radiansToDegrees(atan2(direction.getY(),direction.getX())) def updateBullet(self, task): """if task.time >= 1.0 : self.bullets[n].removeNode() return Task.done""" self.setPos(self.getX() + (0.5 * self.direction.getX()), self.getY() + (0.5 * self.direction.getY()), 0 ) return Task.cont
def setupCollisions(self): #instantiates a collision traverser and sets it to the default base.cTrav = CollisionTraverser() self.cHandler = CollisionHandlerEvent() #set pattern for event sent on collision # "%in" is substituted with the name of the into object self.cHandler.setInPattern("ate-%in") cSphere = CollisionSphere((0,0,200), 450) #because the player is scaled way down self.playerRay = CollisionRay() self.playerRay.setOrigin(0,0,2000) self.playerRay.setDirection(0,0,-1) self.playerNode = CollisionNode("playerRay") self.playerNode.addSolid(self.playerRay) self.playerNode.setFromCollideMask(BitMask32.bit(0)) self.playerNode.setIntoCollideMask(BitMask32.allOff()) self.playerNodePath = self.player.attachNewNode(self.playerNode) self.playerNodePath.show() self.playerGroundHandler = CollisionHandlerFloor() self.playerGroundHandler.addCollider(self.playerNodePath, self.player) base.cTrav.addCollider(self.playerNodePath, self.playerGroundHandler) cNode = CollisionNode("player") cNode.addSolid(cSphere) cNode.setIntoCollideMask(BitMask32.allOff()) #player is *only* a from object #cNode.setFromCollideMask(BitMask32.bit(0)) cNodePath = self.player.attachNewNode(cNode) #registers a from object with the traverser with a corresponding handler base.cTrav.addCollider(cNodePath, self.cHandler) i = 0 for target in self.targets: cSphere = CollisionSphere((0,0,0), 2) cNode = CollisionNode("smiley") cNode.addSolid(cSphere) cNode.setIntoCollideMask(BitMask32.bit(1)) cNode.setTag('target', str(i)) cNodePath = target.attachNewNode(cNode) i += 1
""" #========================================================================= #** Collision events ignition base.cTrav = CollisionTraverser() collisionHandler = CollisionHandlerEvent() #** Setting the ray collider - see step5.py for details pickerNode = CollisionNode('mouseraycnode') pickerNP = base.camera.attachNewNode(pickerNode) pickerRay = CollisionRay() pickerNode.addSolid(pickerRay) #** This is new stuff: we set here a so called 'tag' for the ray - its purpose is to make the ray recognizable in a different event pattern matching # situation from what we are used to use so far. Just note the first parameter is the main object grouping. See details below setting the patterns. pickerNode.setTag('rays', 'ray1') base.cTrav.addCollider(pickerNP, collisionHandler) #** This function is used to create all our smileys in the scene - I won't get into the basic commands that should be clear if you passed by the previous steps. def smileyMachine(n, pos): smileyModel = loader.loadModel('smiley') smileyModel.setName('Smiley#%d' % n) smileyModel.reparentTo(render) smileyModel.setPos(pos) smileyCollider = smileyModel.attachNewNode( CollisionNode('smileycnode%d' % n)) smileyCollider.node().addSolid(CollisionSphere(0, 0, 0, 1)) # we set here the tag to recognize later all the smileys - just note to remember later that the grouping it belongs is called 'balls' and the value tells it is 'smileys'. smileyCollider.setTag('balls', 'smiley')
def setupCollisions(self): base.cTrav = CollisionTraverser() self.playerRay = CollisionRay() self.playerRay.setOrigin(0,0,1000) self.playerRay.setDirection(0,0,-1) self.playerNode = CollisionNode("playerRay") self.playerNode.addSolid(self.playerRay) self.playerNode.setFromCollideMask(BitMask32.bit(0)) self.playerNode.setIntoCollideMask(BitMask32.allOff()) self.playerNodePath = self.player.attachNewNode(self.playerNode) self.playerNodePath.show() self.playerGroundHandler = CollisionHandlerQueue() base.cTrav.addCollider(self.playerNodePath, self.playerGroundHandler) envcNode1 = CollisionNode("lot_bottom") envcNode1.setFromCollideMask(BitMask32.bit(0)) temp = CollisionPolygon(Point3(12.56, 19.182, 0), Point3(12.56, -21.261, 0), Point3(-13.217, -21.261, 0), Point3(-13.217, 19.182, 0)) envcNode1.addSolid(temp) envcNode2 = CollisionNode("lot_ramp_bottom") envcNode2.setFromCollideMask(BitMask32.bit(0)) temp = CollisionPolygon(Point3(32.715, -14.923, 3.5), Point3(32.715, -21.261, 3.5), Point3(12.56, -21.261, 0), Point3(12.56, -14.923, 0)) envcNode2.addSolid(temp) envcNode3 = CollisionNode("lot_middle") envcNode3.setFromCollideMask(BitMask32.bit(0)) temp = CollisionPolygon(Point3(42.715, -14.923, 3.5), Point3(42.715, -21.261, 3.5), Point3(32.715, -21.261, 3.5), Point3(32.715, -14.923, 3.5)) envcNode3.addSolid(temp) envcNode4 = CollisionNode("lot_ramp_top") envcNode4.setFromCollideMask(BitMask32.bit(0)) temp = CollisionPolygon(Point3(42.715, -8.845, 6), Point3(42.715, -14.923, 3.5), Point3(32.715, -14.923, 3.5), Point3(32.715, -8.845, 6)) envcNode4.addSolid(temp) envcNode5 = CollisionNode("lot_top") envcNode5.setFromCollideMask(BitMask32.bit(0)) temp = CollisionPolygon(Point3(42.715, 16.155, 6), Point3(42.715, -8.845, 6), Point3(17.715, -8.845, 6), Point3(17.715, 16.155, 6)) envcNode5.addSolid(temp) wallCNode = CollisionNode("fence") wallCNode.setFromCollideMask(BitMask32.bit(0)) temp = CollisionPolygon(Point3(12.56, 19.182, 0), Point3(12.56, -14.923, 0), Point3(12.56, -14.923, 10), Point3(12.56, 19.182, 10)) wallCNode.addSolid(temp) temp = CollisionPolygon(Point3(12.56, -14.923, 0), Point3(32.715, -14.923, 3.5), Point3(32.715, -14.923, 10), Point3(12.56, -14.923, 10)) wallCNode.addSolid(temp) temp = CollisionPolygon(Point3(32.715, -14.923, 3.5), Point3(32.715, -8.845, 6), Point3(32.715, -8.845, 10), Point3(32.715, -14.923, 10)) wallCNode.addSolid(temp) temp = CollisionPolygon(Point3(32.715, -8.845, 6), Point3(17.715, -8.845, 6), Point3(17.715, -8.845, 10), Point3(32.715, -8.845, 10)) wallCNode.addSolid(temp) temp = CollisionPolygon(Point3(17.715, -8.845, 6), Point3(17.715, 16.155, 6), Point3(17.715, 16.155, 10), Point3(17.715, -8.845, 10)) wallCNode.addSolid(temp) temp = CollisionPolygon(Point3(17.715, 16.155, 6), Point3(42.715, 16.155, 6), Point3(42.715, 16.155, 10), Point3(17.715, 16.155, 10)) wallCNode.addSolid(temp) temp = CollisionPolygon(Point3(42.715, 16.155, 6), Point3(42.715, -8.845, 6), Point3(42.715, -8.845, 10), Point3(42.715, 16.155, 10)) wallCNode.addSolid(temp) temp = CollisionPolygon(Point3(42.715, -8.845, 6), Point3(42.715, -14.923, 3.5), Point3(42.715, -14.923, 10), Point3(42.715, -8.845, 10)) wallCNode.addSolid(temp) temp = CollisionPolygon(Point3(42.715, -14.923, 3.5), Point3(42.715, -21.261, 3.5), Point3(42.715, -21.261, 10), Point3(42.715, -14.923, 10)) wallCNode.addSolid(temp) temp = CollisionPolygon(Point3(42.715, -21.261, 3.5), Point3(32.715, -21.261, 3.5), Point3(32.715, -21.261, 10), Point3(42.715, -21.261, 10)) wallCNode.addSolid(temp) temp = CollisionPolygon(Point3(32.715, -21.261, 3.5), Point3(12.56, -21.261, 0), Point3(12.56, -21.261, 10), Point3(32.715, -21.261, 10)) wallCNode.addSolid(temp) temp = CollisionPolygon(Point3(12.56, -21.261, 0), Point3(-13.217, -21.261, 0), Point3(-13.217, -21.261, 10), Point3(12.56, -21.261, 10)) wallCNode.addSolid(temp) temp = CollisionPolygon(Point3(-13.217, -21.261, 0), Point3(-13.217, 19.182, 0), Point3(-13.217, 19.182, 10), Point3(-13.217, -21.261, 10)) wallCNode.addSolid(temp) temp = CollisionPolygon(Point3(-13.217, 19.182, 0), Point3(12.56, 19.182, 0), Point3(12.56, 19.182, 10), Point3(-13.217, 19.182, 10)) wallCNode.addSolid(temp) envcNodePath1 = self.env.attachNewNode(envcNode1) envcNodePath2 = self.env.attachNewNode(envcNode2) envcNodePath3 = self.env.attachNewNode(envcNode3) envcNodePath4 = self.env.attachNewNode(envcNode4) envcNodePath5 = self.env.attachNewNode(envcNode5) self.cHandler = CollisionHandlerEvent() pusher = CollisionHandlerPusher() self.wallNode = self.env.attachNewNode('wallNode') wallCNodePath = self.wallNode.attachNewNode(wallCNode) if DEBUG: wallCNodePath.show() cNode = CollisionNode("player") temp = CollisionSphere((0,-5.5,10), 4) cNode.addSolid(temp) temp = CollisionSphere((0,-0.5,10), 4) cNode.addSolid(temp) temp = CollisionSphere((0,3.5,10), 4) cNode.addSolid(temp) cNode.setIntoCollideMask(BitMask32.allOff()) #player is *only* a from object cNodePath = self.player.attachNewNode(cNode) if DEBUG: cNodePath.show() base.cTrav.addCollider(cNodePath, pusher) pusher.addCollider(cNodePath, self.player) pusher.addInPattern('%fn-into-%in') self.accept('player-into-fence', self.collideWithFence) self.accept('player-into-staticCar', self.collideOther) self.accept('player-into-droneNode', self.collideOther) self.playerLightCollision = CollisionHandlerEvent() self.playerLightCollision.addInPattern('into-%in') cNode2 = CollisionNode("playerinto") #cNode.addSolid(segment1) #cNode.addSolid(segment2) #cNode.addSolid(segment3) #cNode.addSolid(segment4) temp = CollisionSphere((0,-5.5,1), 4) cNode2.addSolid(temp) temp = CollisionSphere((0,-0.5,1), 4) cNode2.addSolid(temp) temp = CollisionSphere((0,3.5,1), 4) cNode2.addSolid(temp) cNode2.setFromCollideMask(BitMask32.allOff()) #player is *only* a from object cNodePath2 = self.player.attachNewNode(cNode2) if DEBUG: cNodePath2.show() # FLAMETHROWER COLLISIONS # left flamethrowerLeft = CollisionSegment() flamethrowerLeft.setPointA(-2 , -4, 10) flamethrowerLeft.setPointB( -2 , -20 , 10 ) # middle flamethrowerMiddle = CollisionSegment() flamethrowerMiddle.setPointA(0 , -4, 10) flamethrowerMiddle.setPointB( 0 , -20 , 10 ) # right flamethrowerRight = CollisionSegment() flamethrowerRight.setPointA(2, -4, 10) flamethrowerRight.setPointB( 2 , -20 , 10 ) flamethrowerNode = CollisionNode("flamethrower") flamethrowerNode.addSolid(flamethrowerLeft) flamethrowerNode.addSolid(flamethrowerMiddle) flamethrowerNode.addSolid(flamethrowerRight) flamethrowerNode.setIntoCollideMask(BitMask32.allOff()) flamethrowerNode.setFromCollideMask(BitMask32.allOn()) flamethrowerNodePath = self.player.attachNewNode(flamethrowerNode) #flamethrowerNodePath.show() self.flamethrowerCollision = CollisionHandlerEvent() self.flamethrowerCollision.addInPattern('into-%in') base.cTrav.addCollider(flamethrowerNodePath, self.flamethrowerCollision) self.accept('into-droneNode', self.hitEnemy) for i in range(len(self.staticCars)): staticNode = CollisionNode("staticCar") temp = CollisionSphere((0,-5.2,10), 4) staticNode.addSolid(temp) temp = CollisionSphere((0,-0.5,10), 4) staticNode.addSolid(temp) temp = CollisionSphere((0,5.5,10), 4) staticNode.addSolid(temp) staticNode.setIntoCollideMask(BitMask32.bit(1)) staticNode.setFromCollideMask(BitMask32.bit(0)) staticNodePath = self.staticCars[i].attachNewNode(staticNode) temp = CollisionTube(0,7,3,0,-6,3,3.5) sN = CollisionNode("staticTube") sN.addSolid(temp) staticNode.setFromCollideMask(BitMask32.bit(0)) sNP = self.staticCars[i].attachNewNode(sN) sN.setTag('car', str(i)) self.enemyHandler = CollisionHandlerEvent() for i in range(len(self.enemies)): collideNode = CollisionNode("droneNode") temp = CollisionSphere((0,0,10), 4) collideNode.addSolid(temp) collideNode.setIntoCollideMask(BitMask32.bit(1)) collideNode.setFromCollideMask(BitMask32.bit(0)) enemycollideNodePath = self.enemies[i].attachNewNode(collideNode) collideNode.setTag('enemy',str(i)) self.enemies[i].lightRay = CollisionSegment() self.enemies[i].lightRay.setPointA(0, -4, 4) self.enemies[i].lightRay.setPointB( 0 , -100 , 0 ) # left self.enemies[i].lightRayLeft = CollisionSegment() self.enemies[i].lightRayLeft.setPointA(0, -4, 4) self.enemies[i].lightRayLeft.setPointB( -5 , -100 , 0 ) # right self.enemies[i].lightRayRight = CollisionSegment() self.enemies[i].lightRayRight.setPointA(0, -4, 4) self.enemies[i].lightRayRight.setPointB( 5 , -100 , 0 ) self.enemies[i].lightRayNode = CollisionNode("lightRay") self.enemies[i].lightRayNode.addSolid(self.enemies[i].lightRay) self.enemies[i].lightRayNode.addSolid(self.enemies[i].lightRayLeft) self.enemies[i].lightRayNode.addSolid(self.enemies[i].lightRayRight) self.enemies[i].lightRayNode.setTag('enemy',str(i)) self.enemies[i].lightRayNode.setIntoCollideMask(BitMask32.allOff()) self.enemies[i].lightRayNodePath = self.enemies[i].attachNewNode(self.enemies[i].lightRayNode) if DEBUG: self.enemies[i].lightRayNodePath.show() base.cTrav.addCollider(self.enemies[i].lightRayNodePath, self.playerLightCollision) self.accept('into-playerinto', self.player.takeHit)
def makeCrunchTrack(self): toonId = self.toon toon = base.cr.doId2do.get(toonId) if not toon: return self.virtualSuit.lookAt(toon) if self.virtualSuit.style.body in ['a', 'b']: throwDelay = 3 elif self.virtualSuit.style.body == 'c': throwDelay = 2.3 else: throwDelay = 2 numberNames = ['one', 'two', 'three', 'four', 'five', 'six'] BattleParticles.loadParticles() numberSpill1 = BattleParticles.createParticleEffect(file='numberSpill') numberSpill2 = BattleParticles.createParticleEffect(file='numberSpill') spillTexture1 = random.choice(numberNames) spillTexture2 = random.choice(numberNames) BattleParticles.setEffectTexture(numberSpill1, 'audit-' + spillTexture1) BattleParticles.setEffectTexture(numberSpill2, 'audit-' + spillTexture2) numberSpillTrack1 = getPartTrack(numberSpill1, 1.1, 2.2, [numberSpill1, self.virtualSuit, 0]) numberSpillTrack2 = getPartTrack(numberSpill2, 1.5, 1.0, [numberSpill2, self.virtualSuit, 0]) numberSprayTracks = Parallel() numOfNumbers = random.randint(5, 9) for i in xrange(0, numOfNumbers - 1): nextSpray = BattleParticles.createParticleEffect(file='numberSpray') nextTexture = random.choice(numberNames) BattleParticles.setEffectTexture(nextSpray, 'audit-' + nextTexture) nextStartTime = random.random() * 0.6 + 3.03 nextDuration = random.random() * 0.4 + 1.4 nextSprayTrack = getPartTrack(nextSpray, nextStartTime, nextDuration, [nextSpray, self.virtualSuit, 0]) numberSprayTracks.append(nextSprayTrack) def throwProp(prop): if not self.virtualSuit: return toon = self.cr.doId2do.get(toonId) if not toon: self.cleanupProp(prop, False) self.finishPropAttack() return self.virtualSuit.lookAt(toon) prop.wrtReparentTo(render) hitPos = toon.getPos() + Vec3(0, 0, 2.5) distance = (prop.getPos() - hitPos).length() speed = 50.0 throwSequence = Sequence( prop.posInterval(distance / speed, hitPos), Func(self.cleanupProp, prop, False) ) throwSequence.start() numberTracks = Parallel() for i in xrange(0, numOfNumbers): texture = random.choice(numberNames) next = copyProp(BattleParticles.getParticle('audit-' + texture)) next.reparentTo(self.virtualSuit.getRightHand()) next.setScale(0.01, 0.01, 0.01) next.setColor(Vec4(0.0, 0.0, 0.0, 1.0)) next.setPos(random.random() * 0.6 - 0.3, random.random() * 0.6 - 0.3, random.random() * 0.6 - 0.3) next.setHpr(VBase3(-1.15, 86.58, -76.78)) # Make prop virtual: next.setColorScale(1.0, 0.0, 0.0, 0.8) next.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd)) # Prop collisions: colNode = CollisionNode(self.uniqueName('SuitAttack')) colNode.setTag('damage', str(self.attackInfo[1])) bounds = next.getBounds() center = bounds.getCenter() radius = bounds.getRadius() sphere = CollisionSphere(center.getX(), center.getY(), center.getZ(), radius) sphere.setTangible(0) colNode.addSolid(sphere) colNode.setIntoCollideMask(WallBitmask) next.attachNewNode(colNode) numberTrack = Sequence( Wait(throwDelay), Parallel( LerpScaleInterval(next, 0.6, Point3(1.0, 1.0, 1.0)), Func(throwProp, next), ), ) numberTracks.append(numberTrack) suitTrack = Parallel( Func(self.sayFaceoffTaunt), Sequence( ActorInterval(self.virtualSuit, 'throw-object'), ActorInterval(self.virtualSuit, 'neutral') ), ) return Sequence( Parallel( suitTrack, numberSpillTrack1, numberSpillTrack2, numberTracks, numberSprayTracks ), Func(self.virtualSuit.loop, 'walk', 0), Func(self.virtualSuit.setHpr, 0, 0, 0), )
def makeWriteOffTrack(self): pad = BattleProps.globalPropPool.getProp('pad') pad.setScale(1.89) pencil = BattleProps.globalPropPool.getProp('pencil') BattleParticles.loadParticles() checkmark = copyProp(BattleParticles.getParticle('checkmark')) checkmark.setBillboardPointEye() # Make prop virtual: pad.setColorScale(1.0, 0.0, 0.0, 0.8) pad.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd)) pencil.setColorScale(1.0, 0.0, 0.0, 0.8) pencil.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd)) checkmark.setColorScale(1.0, 0.0, 0.0, 0.8) checkmark.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd)) # Prop collisions: colNode = CollisionNode(self.uniqueName('SuitAttack')) colNode.setTag('damage', str(self.attackInfo[1])) bounds = checkmark.getBounds() center = bounds.getCenter() radius = bounds.getRadius() sphere = CollisionSphere(center.getX(), center.getY(), center.getZ(), radius) sphere.setTangible(0) colNode.addSolid(sphere) colNode.setIntoCollideMask(WallBitmask) checkmark.attachNewNode(colNode) toonId = self.toon toon = base.cr.doId2do.get(toonId) if not toon: return self.virtualSuit.lookAt(toon) if self.virtualSuit.style.body in ['a', 'b']: throwDelay = 3 elif self.virtualSuit.style.body == 'c': throwDelay = 2.3 else: throwDelay = 2 def throwProp(): if not self.virtualSuit: return toon = self.cr.doId2do.get(toonId) if not toon: self.cleanupProp(checkmark, False) self.finishPropAttack() return self.virtualSuit.lookAt(toon) checkmark.wrtReparentTo(render) hitPos = toon.getPos() + Vec3(0, 0, 2.5) distance = (checkmark.getPos() - hitPos).length() speed = 50.0 if self.attackProp == 'teeth': throwSequence = Sequence( Parallel( checkmark.posInterval(distance / speed, hitPos), ActorInterval(checkmark, 'teeth', duration=distance / speed), ), Func(self.cleanupProp, checkmark, False), ) else: throwSequence = Sequence( checkmark.posInterval(distance / speed, hitPos), Func(self.cleanupProp, checkmark, False) ) throwSequence.start() pencilTrack = Sequence( Wait(0.5), Func(pencil.setPosHpr, -0.47, 1.08, 0.28, 21.045, 12.702, -176.374), Func(pencil.reparentTo, self.virtualSuit.getRightHand()), LerpScaleInterval(pencil, 0.5, Point3(1.5, 1.5, 1.5), startScale=Point3(0.01)), Wait(throwDelay), Func(checkmark.reparentTo, render), Func(checkmark.setScale, 1.6), Func(checkmark.setPosHpr, pencil, 0, 0, 0, 0, 0, 0), Func(checkmark.setP, 0), Func(checkmark.setR, 0), Func(throwProp), Wait(0.3), LerpScaleInterval(pencil, 0.5, Point3(0.01, 0.01, 0.01)), Func(pencil.removeNode), ) suitTrack = Sequence( ActorInterval(self.virtualSuit, 'hold-pencil'), Func(self.virtualSuit.loop, 'neutral', 0), ) soundTrack = Sequence( Wait(2.3), SoundInterval(self.writeOffSfx, duration=0.9, node=self.virtualSuit), SoundInterval(self.dingSfx, node=self.virtualSuit) ) padTrack = Track( (0.0, Func(pad.setPosHpr, -0.25, 1.38, -0.08, -19.078, -6.603, -171.594)), (0.4, Func(pad.reparentTo, self.virtualSuit.getLeftHand())), (3.0, Func(pad.removeNode)), ) track = Sequence( Parallel( suitTrack, soundTrack, padTrack, pencilTrack, Func(self.sayFaceoffTaunt) ), Func(self.virtualSuit.loop, 'walk', 0) ) return track
def makePropAttackTrack(self): prop = BattleProps.globalPropPool.getProp(self.attackProp) propIsActor = True animName = 'throw-paper' x, y, z, h, p, r = (0.1, 0.2, -0.35, 0, 336, 0) if self.attackProp == 'redtape': animName = 'throw-object' x, y, z, h, p, r = (0.24, 0.09, -0.38, -1.152, 86.581, -76.784) propIsActor = False elif self.attackProp == 'newspaper': animName = 'throw-object' propIsActor = False x, y, z, h, p, r = (-0.07, 0.17, -0.13, 161.867, -33.149, -48.086) prop.setScale(4) elif self.attackProp == 'pink-slip': animName = 'throw-paper' propIsActor = False x, y, z, h, p, r = (0.07, -0.06, -0.18, -172.075, -26.715, -89.131) prop.setScale(5) elif self.attackProp == 'power-tie': animName = 'throw-paper' propIsActor = False x, y, z, h, p, r = (1.16, 0.24, 0.63, 171.561, 1.745, -163.443) prop.setScale(4) elif self.attackProp == 'baseball': animName = 'throw-object' propIsActor = False x, y, z, h, p, r = (0.04, 0.03, -0.31, 0, 336, 0) prop.setScale(4) elif self.attackProp == 'teeth': animName = 'throw-object' propIsActor = True x, y, z, h, p, r = -0.05, 0.41, -0.54, 4.465, -3.563, 51.479 prop.setScale(3) elif self.attackProp == 'golf-ball': propIsActor = False x, y, z = self.getGolfStartPoint() h, p, r = 0, 0, 0 prop.setScale(1.5) # Make prop virtual: prop.setColorScale(1.0, 0.0, 0.0, 0.8) prop.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd)) # Prop collisions: colNode = CollisionNode(self.uniqueName('SuitAttack')) colNode.setTag('damage', str(self.attackInfo[1])) bounds = prop.getBounds() center = bounds.getCenter() radius = bounds.getRadius() sphere = CollisionSphere(center.getX(), center.getY(), center.getZ(), radius) sphere.setTangible(0) colNode.addSolid(sphere) colNode.setIntoCollideMask(WallBitmask) prop.attachNewNode(colNode) toonId = self.toon toon = base.cr.doId2do.get(toonId) if not toon: return self.virtualSuit.lookAt(toon) if self.virtualSuit.style.body in ['a', 'b']: throwDelay = 3 elif self.virtualSuit.style.body == 'c': throwDelay = 2.3 else: throwDelay = 2 def throwProp(): if not self.virtualSuit: return toon = self.cr.doId2do.get(toonId) if not toon: self.cleanupProp(prop, propIsActor) self.finishPropAttack() return self.virtualSuit.lookAt(toon) prop.wrtReparentTo(render) hitPos = toon.getPos() + Vec3(0, 0, 2.5) distance = (prop.getPos() - hitPos).length() speed = 50.0 if self.attackProp == 'golf-ball': speed *= 2 if self.attackProp == 'teeth': throwSequence = Sequence( Parallel( prop.posInterval(distance / speed, hitPos), ActorInterval(prop, 'teeth', duration=distance / speed), ), Func(self.cleanupProp, prop, propIsActor), ) else: throwSequence = Sequence( prop.posInterval(distance / speed, hitPos), Func(self.cleanupProp, prop, propIsActor) ) throwSequence.start() if self.attackProp == 'golf-ball': club = BattleProps.globalPropPool.getProp('golf-club') club.setScale(1.1) track = Sequence( Parallel( Track( (0.4, Func(club.reparentTo, self.virtualSuit.getRightHand())), (0.0, Func(club.setPosHpr, 0.0, 0.0, 0.0, 63.097, 43.988, -18.435)), (0.0, Func(prop.reparentTo, self.virtualSuit)), (0.0, Func(prop.setPosHpr, x, y, z, h, p, r)), (0.0, Func(self.sayFaceoffTaunt)), (0.1, Sequence( ActorInterval(self.virtualSuit, 'golf-club-swing'), Func(self.virtualSuit.loop, 'neutral', 0)) ), (4.1, SoundInterval(self.teeOffSfx, node=self.virtualSuit)), (throwDelay + 1.5, Func(throwProp)), (throwDelay + 2, Func(club.removeNode)), (throwDelay + 3, Func(self.finishPropAttack)) ), ), Func(self.virtualSuit.setHpr, 0, 0, 0), Func(self.virtualSuit.loop, 'walk', 0), ) else: track = Sequence( Parallel( Sequence( ActorInterval(self.virtualSuit, animName), Func(self.virtualSuit.loop, 'neutral', 0) ), Track( (0.4, Func(prop.reparentTo, self.virtualSuit.getRightHand())), (0.0, Func(prop.setPosHpr, x, y, z, h, p, r)), (0.0, Func(self.sayFaceoffTaunt)), (throwDelay, Func(throwProp)), (throwDelay + 2, Func(self.finishPropAttack)) ), ), Func(self.virtualSuit.setHpr, 0, 0, 0), Func(self.virtualSuit.loop, 'walk', 0), ) track.prop = prop track.propIsActor = propIsActor return track
def makeCrunchTrack(self): toonId = self.toon toon = base.cr.doId2do.get(toonId) if not toon: return self.virtualSuit.lookAt(toon) if self.virtualSuit.style.body in ['a', 'b']: throwDelay = 3 elif self.virtualSuit.style.body == 'c': throwDelay = 2.3 else: throwDelay = 2 numberNames = ['one', 'two', 'three', 'four', 'five', 'six'] BattleParticles.loadParticles() numberSpill1 = BattleParticles.createParticleEffect(file='numberSpill') numberSpill2 = BattleParticles.createParticleEffect(file='numberSpill') spillTexture1 = random.choice(numberNames) spillTexture2 = random.choice(numberNames) BattleParticles.setEffectTexture(numberSpill1, 'audit-' + spillTexture1) BattleParticles.setEffectTexture(numberSpill2, 'audit-' + spillTexture2) numberSpillTrack1 = getPartTrack(numberSpill1, 1.1, 2.2, [numberSpill1, self.virtualSuit, 0]) numberSpillTrack2 = getPartTrack(numberSpill2, 1.5, 1.0, [numberSpill2, self.virtualSuit, 0]) numberSprayTracks = Parallel() numOfNumbers = random.randint(5, 9) for i in xrange(0, numOfNumbers - 1): nextSpray = BattleParticles.createParticleEffect( file='numberSpray') nextTexture = random.choice(numberNames) BattleParticles.setEffectTexture(nextSpray, 'audit-' + nextTexture) nextStartTime = random.random() * 0.6 + 3.03 nextDuration = random.random() * 0.4 + 1.4 nextSprayTrack = getPartTrack(nextSpray, nextStartTime, nextDuration, [nextSpray, self.virtualSuit, 0]) numberSprayTracks.append(nextSprayTrack) def throwProp(prop): if not self.virtualSuit: return toon = self.cr.doId2do.get(toonId) if not toon: self.cleanupProp(prop, False) self.finishPropAttack() return self.virtualSuit.lookAt(toon) prop.wrtReparentTo(render) hitPos = toon.getPos() + Vec3(0, 0, 2.5) distance = (prop.getPos() - hitPos).length() speed = 50.0 throwSequence = Sequence( prop.posInterval(distance / speed, hitPos), Func(self.cleanupProp, prop, False)) throwSequence.start() numberTracks = Parallel() for i in xrange(0, numOfNumbers): texture = random.choice(numberNames) next = copyProp(BattleParticles.getParticle('audit-' + texture)) next.reparentTo(self.virtualSuit.getRightHand()) next.setScale(0.01, 0.01, 0.01) next.setColor(Vec4(0.0, 0.0, 0.0, 1.0)) next.setPos(random.random() * 0.6 - 0.3, random.random() * 0.6 - 0.3, random.random() * 0.6 - 0.3) next.setHpr(VBase3(-1.15, 86.58, -76.78)) # Make prop virtual: next.setColorScale(1.0, 0.0, 0.0, 0.8) next.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd)) # Prop collisions: colNode = CollisionNode(self.uniqueName('SuitAttack')) colNode.setTag('damage', str(self.attackInfo[1])) bounds = next.getBounds() center = bounds.getCenter() radius = bounds.getRadius() sphere = CollisionSphere(center.getX(), center.getY(), center.getZ(), radius) sphere.setTangible(0) colNode.addSolid(sphere) colNode.setIntoCollideMask(WallBitmask) next.attachNewNode(colNode) numberTrack = Sequence( Wait(throwDelay), Parallel( LerpScaleInterval(next, 0.6, Point3(1.0, 1.0, 1.0)), Func(throwProp, next), ), ) numberTracks.append(numberTrack) suitTrack = Parallel( Func(self.sayFaceoffTaunt), Sequence(ActorInterval(self.virtualSuit, 'throw-object'), ActorInterval(self.virtualSuit, 'neutral')), ) return Sequence( Parallel(suitTrack, numberSpillTrack1, numberSpillTrack2, numberTracks, numberSprayTracks), Func(self.virtualSuit.loop, 'walk', 0), Func(self.virtualSuit.setHpr, 0, 0, 0), )
def makeWriteOffTrack(self): pad = BattleProps.globalPropPool.getProp('pad') pad.setScale(1.89) pencil = BattleProps.globalPropPool.getProp('pencil') BattleParticles.loadParticles() checkmark = copyProp(BattleParticles.getParticle('checkmark')) checkmark.setBillboardPointEye() # Make prop virtual: pad.setColorScale(1.0, 0.0, 0.0, 0.8) pad.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd)) pencil.setColorScale(1.0, 0.0, 0.0, 0.8) pencil.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd)) checkmark.setColorScale(1.0, 0.0, 0.0, 0.8) checkmark.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd)) # Prop collisions: colNode = CollisionNode(self.uniqueName('SuitAttack')) colNode.setTag('damage', str(self.attackInfo[1])) bounds = checkmark.getBounds() center = bounds.getCenter() radius = bounds.getRadius() sphere = CollisionSphere(center.getX(), center.getY(), center.getZ(), radius) sphere.setTangible(0) colNode.addSolid(sphere) colNode.setIntoCollideMask(WallBitmask) checkmark.attachNewNode(colNode) toonId = self.toon toon = base.cr.doId2do.get(toonId) if not toon: return self.virtualSuit.lookAt(toon) if self.virtualSuit.style.body in ['a', 'b']: throwDelay = 3 elif self.virtualSuit.style.body == 'c': throwDelay = 2.3 else: throwDelay = 2 def throwProp(): if not self.virtualSuit: return toon = self.cr.doId2do.get(toonId) if not toon: self.cleanupProp(checkmark, False) self.finishPropAttack() return self.virtualSuit.lookAt(toon) checkmark.wrtReparentTo(render) hitPos = toon.getPos() + Vec3(0, 0, 2.5) distance = (checkmark.getPos() - hitPos).length() speed = 50.0 if self.attackProp == 'teeth': throwSequence = Sequence( Parallel( checkmark.posInterval(distance / speed, hitPos), ActorInterval(checkmark, 'teeth', duration=distance / speed), ), Func(self.cleanupProp, checkmark, False), ) else: throwSequence = Sequence( checkmark.posInterval(distance / speed, hitPos), Func(self.cleanupProp, checkmark, False)) throwSequence.start() pencilTrack = Sequence( Wait(0.5), Func(pencil.setPosHpr, -0.47, 1.08, 0.28, 21.045, 12.702, -176.374), Func(pencil.reparentTo, self.virtualSuit.getRightHand()), LerpScaleInterval(pencil, 0.5, Point3(1.5, 1.5, 1.5), startScale=Point3(0.01)), Wait(throwDelay), Func(checkmark.reparentTo, render), Func(checkmark.setScale, 1.6), Func(checkmark.setPosHpr, pencil, 0, 0, 0, 0, 0, 0), Func(checkmark.setP, 0), Func(checkmark.setR, 0), Func(throwProp), Wait(0.3), LerpScaleInterval(pencil, 0.5, Point3(0.01, 0.01, 0.01)), Func(pencil.removeNode), ) suitTrack = Sequence( ActorInterval(self.virtualSuit, 'hold-pencil'), Func(self.virtualSuit.loop, 'neutral', 0), ) soundTrack = Sequence( Wait(2.3), SoundInterval(self.writeOffSfx, duration=0.9, node=self.virtualSuit), SoundInterval(self.dingSfx, node=self.virtualSuit)) padTrack = Track( (0.0, Func(pad.setPosHpr, -0.25, 1.38, -0.08, -19.078, -6.603, -171.594)), (0.4, Func(pad.reparentTo, self.virtualSuit.getLeftHand())), (3.0, Func(pad.removeNode)), ) track = Sequence( Parallel(suitTrack, soundTrack, padTrack, pencilTrack, Func(self.sayFaceoffTaunt)), Func(self.virtualSuit.loop, 'walk', 0)) return track
def makePropAttackTrack(self): prop = BattleProps.globalPropPool.getProp(self.attackProp) propIsActor = True animName = 'throw-paper' x, y, z, h, p, r = (0.1, 0.2, -0.35, 0, 336, 0) if self.attackProp == 'redtape': animName = 'throw-object' x, y, z, h, p, r = (0.24, 0.09, -0.38, -1.152, 86.581, -76.784) propIsActor = False elif self.attackProp == 'newspaper': animName = 'throw-object' propIsActor = False x, y, z, h, p, r = (-0.07, 0.17, -0.13, 161.867, -33.149, -48.086) prop.setScale(4) elif self.attackProp == 'pink-slip': animName = 'throw-paper' propIsActor = False x, y, z, h, p, r = (0.07, -0.06, -0.18, -172.075, -26.715, -89.131) prop.setScale(5) elif self.attackProp == 'power-tie': animName = 'throw-paper' propIsActor = False x, y, z, h, p, r = (1.16, 0.24, 0.63, 171.561, 1.745, -163.443) prop.setScale(4) elif self.attackProp == 'baseball': animName = 'throw-object' propIsActor = False x, y, z, h, p, r = (0.04, 0.03, -0.31, 0, 336, 0) prop.setScale(4) elif self.attackProp == 'teeth': animName = 'throw-object' propIsActor = True x, y, z, h, p, r = -0.05, 0.41, -0.54, 4.465, -3.563, 51.479 prop.setScale(3) elif self.attackProp == 'golf-ball': propIsActor = False x, y, z = self.getGolfStartPoint() h, p, r = 0, 0, 0 prop.setScale(1.5) # Make prop virtual: prop.setColorScale(1.0, 0.0, 0.0, 0.8) prop.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd)) # Prop collisions: colNode = CollisionNode(self.uniqueName('SuitAttack')) colNode.setTag('damage', str(self.attackInfo[1])) bounds = prop.getBounds() center = bounds.getCenter() radius = bounds.getRadius() sphere = CollisionSphere(center.getX(), center.getY(), center.getZ(), radius) sphere.setTangible(0) colNode.addSolid(sphere) colNode.setIntoCollideMask(WallBitmask) prop.attachNewNode(colNode) toonId = self.toon toon = base.cr.doId2do.get(toonId) if not toon: return self.virtualSuit.lookAt(toon) if self.virtualSuit.style.body in ['a', 'b']: throwDelay = 3 elif self.virtualSuit.style.body == 'c': throwDelay = 2.3 else: throwDelay = 2 def throwProp(): if not self.virtualSuit: return toon = self.cr.doId2do.get(toonId) if not toon: self.cleanupProp(prop, propIsActor) self.finishPropAttack() return self.virtualSuit.lookAt(toon) prop.wrtReparentTo(render) hitPos = toon.getPos() + Vec3(0, 0, 2.5) distance = (prop.getPos() - hitPos).length() speed = 50.0 if self.attackProp == 'golf-ball': speed *= 2 if self.attackProp == 'teeth': throwSequence = Sequence( Parallel( prop.posInterval(distance / speed, hitPos), ActorInterval(prop, 'teeth', duration=distance / speed), ), Func(self.cleanupProp, prop, propIsActor), ) else: throwSequence = Sequence( prop.posInterval(distance / speed, hitPos), Func(self.cleanupProp, prop, propIsActor)) throwSequence.start() if self.attackProp == 'golf-ball': club = BattleProps.globalPropPool.getProp('golf-club') club.setScale(1.1) track = Sequence( Parallel( Track( (0.4, Func(club.reparentTo, self.virtualSuit.getRightHand())), (0.0, Func(club.setPosHpr, 0.0, 0.0, 0.0, 63.097, 43.988, -18.435)), (0.0, Func(prop.reparentTo, self.virtualSuit)), (0.0, Func(prop.setPosHpr, x, y, z, h, p, r)), (0.0, Func(self.sayFaceoffTaunt)), (0.1, Sequence( ActorInterval(self.virtualSuit, 'golf-club-swing'), Func(self.virtualSuit.loop, 'neutral', 0))), (4.1, SoundInterval(self.teeOffSfx, node=self.virtualSuit)), (throwDelay + 1.5, Func(throwProp)), (throwDelay + 2, Func(club.removeNode)), (throwDelay + 3, Func(self.finishPropAttack))), ), Func(self.virtualSuit.setHpr, 0, 0, 0), Func(self.virtualSuit.loop, 'walk', 0), ) else: track = Sequence( Parallel( Sequence(ActorInterval(self.virtualSuit, animName), Func(self.virtualSuit.loop, 'neutral', 0)), Track((0.4, Func(prop.reparentTo, self.virtualSuit.getRightHand())), (0.0, Func(prop.setPosHpr, x, y, z, h, p, r)), (0.0, Func(self.sayFaceoffTaunt)), (throwDelay, Func(throwProp)), (throwDelay + 2, Func(self.finishPropAttack))), ), Func(self.virtualSuit.setHpr, 0, 0, 0), Func(self.virtualSuit.loop, 'walk', 0), ) track.prop = prop track.propIsActor = propIsActor return track