예제 #1
0
    def initActor(self):
        faEmpty = self.stage.find("**/{}_{}".format(self.name,
                                                    self.indexNumber))
        faPos = faEmpty.getPos()
        self.actor = Actor(
            "{}".format(self.modelName), {
                "idle": "{}-idle".format(self.modelName),
                "walk": "{}-walk".format(self.modelName)
            })
        self.actor.reparentTo(self.stage)
        self.actor.setPos(faPos)

        cNode = CollisionNode("{}_{}".format(self.name, self.indexNumber))
        cNode.addSolid(CollisionBox(0, 1.5, 1.5, 1))
        faCollision = self.actor.attachNewNode(cNode)
        #####################################################
        # faCollision.show()
        #####################################################
        base.pusher.addCollider(faCollision, self.actor, base.drive.node())
        base.cTrav.addCollider(faCollision, base.pusher)
        self.actorsList.append(self)

        AIchar = AICharacter("{}_{}".format(self.name, self.indexNumber),
                             self.actor, 100, 0.05, 5)
        base.AIworld.addAiChar(AIchar)
        self.AIbehaviors = AIchar.getAiBehaviors()
예제 #2
0
    def __init__(self, base, location, team):
        #assign what we know off the bat
        #TODO chosen model currently depends on team - 0 is friendly, 1 is enemy
        if team == 0:
            self.model = "models/friend_rifleman"
        elif team == 1:
            self.model = "models/enemy_rifleman"
        self.viewRange = 400  #used by application to determine what character can 'see'
        self.contacts = []  #stores nearby objects
        self.target = None  #stores target
        self.goal = None  #stores movement goal (if any)
        self.team = team
        #make call to parent with this model
        entity.__init__(self, self.model, base, location)
        #add rifle to the rifleman, as one does
        self.weaponNode = self.exposeJoint(None, "modelRoot", "weaponNode")
        self.weapon = carbine(self, self.weaponNode)
        self.pose("highReady", 0)

        #add AI to this object
        #mass 60, movement force 0.05, max force 25
        self.ai = AICharacter(str(self), self, 30, 0.05, 25)
        base.AIworld.addAiChar(self.ai)
        self.AiBehaviors = self.ai.getAiBehaviors()
        #load navmesh
        self.AiBehaviors.initPathFind(base.navmesh)
        #add all structures
        for building in base.structures:
            #this is super aggressive so disable for now..
            self.AiBehaviors.addStaticObstacle(building)
예제 #3
0
파일: enemy.py 프로젝트: PlumpMath/spanda3D
 def setAI(self):
     self.AIchar = AICharacter("enemy", self.np, 100, 10., 50)
     self.base.AIworld.addAiChar(self.AIchar)
     self.AIbehaviors = self.AIchar.getAiBehaviors()
     # self.AIbehaviors.wander(50, 0, 1000, 1.0)
     # self.AIbehaviors.seek(self.base.fighter)
     self.AIbehaviors.evade(self.base.fighter, 1000, 2000)
예제 #4
0
파일: CogAI.py 프로젝트: zurgeg/Doomsday
 def setAI(self):
     collisions = render.getPythonTag('WorldCollisions')
     collisions.addCogGroundCollision(self.cog)
     self.AIWorld = AIWorld(render)
     self.AIChar = AICharacter('Cog', self.cog.getCog(), -125, 90, -14)
     self.AIWorld.addAiChar(self.AIChar)
     self.AIBehaviors = self.AIChar.getAiBehaviors()
     if self.support == False:
         self.AIBehaviors.pathFollow(8)
         self.AIBehaviors.addToPath(VBase3(110.60, -0.32, 4.57))
         checkpoints = self.spawn.getPath().getCheckpoints()
         for checkpoint in xrange(len(checkpoints)):
             self.AIBehaviors.addToPath(checkpoints[checkpoint].getPos())
         self.AIBehaviors.startFollow()
     else:
         self.AIBehaviors.pursue(render.find('**/Toon'))
     self.cog.getCog().loop('walk')
     base.taskMgr.add(self.AIUpdate, "AIUpdate")
예제 #5
0
    def __init__(self, parent, model, name, ai_world, mass, movt_force,
                 max_force):
        PhysicalNode.__init__(self, parent, model, name)

        self.mass = mass
        self.addCollisionSphere(1.25)

        self.toggleWalkAnimation()

        #-----------------------------------------------------------------------
        # Initialize Artificial Intelligence
        #-----------------------------------------------------------------------
        self.ai_char = AICharacter("ai_%s" % name, self.actor, mass,
                                   movt_force, max_force)
        ai_world.addAiChar(self.ai_char)
        aiBehaviors = self.ai_char.getAiBehaviors()
        equismo = base.gameState.currentState.objects['equismo']
        aiBehaviors.pursue(equismo.actor)
예제 #6
0
    def __init__(self, nodePath):
        NodePath.__init__(self, nodePath)

        self.actorHandle = None
        if isinstance(nodePath, Actor):
            self.actorHandle = nodePath

        self.aiCharHandle = AICharacter(nodePath.getName(), nodePath, 0.01,
                                        0.01, 0.01)

        # default properties for a GameObject
        self.name = self.getName()
        self.scripts = {
        }  # {string triggerType : list of string scriptTags} TODO: argsList
        self.passable = True
        #self.lifeStatus = LifeStatus.INANIMATE
        self.lifeStatus = LifeStatus.ALIVE
        self.curHP = 1  # CONSIDER: bundle HP and LifeStatus together
        self.maxHP = 1
        self.strategy = Strategy.NEUTRAL
        self.spells = []
        self.stopThreshold = 60

        self.__processTags()