Пример #1
0
    def fireLaser(self, target):
        self.eyeLaser.show()
        self.eyeLaser.wrtReparentTo(render)
        self.eyeLaser.show()
        self.eyeLaser.lookAt(
            target, 0, 0,
            0 if not hasattr(target, 'height') else target.height / 2.0)
        self.eyeLaser.setP(self.eyeLaser.getP() + 90)

        Sequence(Wait(1.0), Func(self.resetEyeLaser)).start()

        pDir = self.eyeLaser.getQuat(render).xform(Vec3.down())
        pPos = self.eyeLaser.getPos(render)
        pFrom = pPos + (pDir * 1.01)
        pTo = pPos + (pDir * 50)
        result = base.physicsWorld.rayTestClosest(pFrom, pTo)
        if result.hasHit():
            node = result.getNode()
            mask = node.getIntoCollideMask()
            point = result.getHitPos()
            dist = (point - pPos).length()
            self.eyeLaser.setScale(1, 1, dist)
            if not (mask & CIGlobals.LocalAvGroup).isZero():
                if node.hasPythonTag("localAvatar"):
                    char = node.getPythonTag("localAvatar")
                    self.onHitLocalAvatar(
                        char, CIGlobals.calcAttackDamage(dist, 5, 50))
        else:
            self.eyeLaser.setScale(1, 1, 50)
 def calcDamage(self, distance=10.0):
     return CIGlobals.calcAttackDamage(distance, self.getBaseDamage(),
                                       self.getDamageMaxDistance())
Пример #3
0
 def calcDamage(self, distance):
     return CIGlobals.calcAttackDamage(distance, self.BaseDamage,
                                       self.MaxDistance)