def delete(self):
     self.stopPosHprBroadcast()
     if self.brain:
         self.brain.stop()
         self.brain = None
     DistributedEntityAI.delete(self)
     DistributedAvatarAI.delete(self)
Example #2
0
    def __init__(self, air, dispatch):
        DistributedAvatarAI.__init__(self, air)
        BaseNPCAI.__init__(self, dispatch)
        self.setDispatch(dispatch)

        self.patrolTime = 0.0
        self.patrolDur = 10.0

        self.activities = {
            ACT_WAKE_ANGRY: 2.0,
            ACT_DIE: -1,
            ACT_GOON_SCAN: 6.0
        }

        self.schedules.update({
            "SCAN_AREA":
            Schedule([
                Task_StopMoving(self),
                Task_GetRandomPath(self),
                Task_RunPath(self),
                Task_AwaitMovement(self),
                Task_SetActivity(self, ACT_GOON_SCAN),
                Task_AwaitActivity(self)
            ],
                     interruptMask=COND_NEW_TARGET | COND_LIGHT_DAMAGE
                     | COND_HEAVY_DAMAGE)
        })

        self.brain = None
        self.spawnflags = 0

        self.health = 25
        self.maxHealth = 25
Example #3
0
    def announceGenerate(self):
        DistributedAvatarAI.announceGenerate(self)
        self.clearTrack()

        self.startAI()

        # Let's set the combo data task name and start the task.
        self.comboDataTaskName = self.uniqueName('clearComboData')
        taskMgr.add(self.clearComboData, self.comboDataTaskName)

        #dur = 8

        #Sequence(
        #    Func(self.setH, 90),
        #    Wait(0.5),
        #    self.posInterval(dur, (-25, 0, 0), (25, 0, 0), blendType = 'easeInOut'),
        #    Wait(0.5),
        #    Func(self.setH, -90),
        #    Wait(0.5),
        #    self.posInterval(dur, (25, 0, 0), (-25, 0, 0), blendType = 'easeInOut'),
        #    Wait(0.5)
        #    )#.loop()
        #self.setH(90)

        self.startPosHprBroadcast()
Example #4
0
 def announceGenerate(self):
     DistributedAvatarAI.announceGenerate(self)
     if self.cEntity:
         self.setPos(self.cEntity.getOrigin())
         self.setHpr(self.cEntity.getAngles())
     self.startPosHprBroadcast()
     self.startAI()
Example #5
0
    def think(self):
        DistributedAvatarAI.think(self)

        dt = globalClock.getDt()

        if not self.isStunned and self.canStun:
            if self.currStunDamage >= self.StunDamage:
                self.changeSchedule(self.getScheduleByName("STUN"))
                self.currStunDamage = 0
            else:
                self.currStunDamage = max(
                    0, self.currStunDamage - (self.StunDecayRate * dt))

        #print(self.currStunDamage)

        now = globalClock.getFrameTime()
        if (now - self.lastSpawnTime >= self.spawnIval and not self.isDead()
                and self.numSuits < self.maxSuits
                and self.npcState != STATE_SCRIPT):
            rearOrFront = random.randint(0, 1)
            if rearOrFront == 0:
                ival = Sequence(Func(self.sendUpdate, 'openRearDoor'),
                                Func(self.spawnDoorSuit, rearOrFront),
                                Wait(4.0),
                                Func(self.sendUpdate, 'closeRearDoor'))
            else:
                ival = Sequence(Func(self.sendUpdate, 'openFrontDoor'),
                                Func(self.spawnDoorSuit, rearOrFront),
                                Wait(4.0),
                                Func(self.sendUpdate, 'closeFrontDoor'))
            ival.start()
            self.lastSpawnTime = now
            self.getSpawnIval()
Example #6
0
    def delete(self):
        taskMgr.remove(self.taskName("eyesLookTask"))
        if self.eyeLensNP:
            self.eyeLensNP.removeNode()
        self.eyeLensNP = None
        self.anim = None
        self.eyeLookType = None

        DistributedAvatarAI.delete(self)
Example #7
0
 def delete(self):
     self.stopAI()
     self.stopPosHprBroadcast()
     self.didFadeOut = None
     self.idealEyeColor = None
     self.hatType = None
     self.patrolTime = None
     self.patrolDur = None
     DistributedAvatarAI.delete(self)
Example #8
0
 def announceGenerate(self):
     DistributedAvatarAI.announceGenerate(self)
     if self.cEntity:
         self.setPos(self.cEntity.getOrigin())
         self.setHpr(self.cEntity.getAngles())
     self.startPosHprBroadcast()
     self.enableThink()
     self.setNPCState(STATE_SCRIPT)
     self.startAI()
     self.changeSchedule(self.getScheduleByName("OPENING_SPEECH"), False)
Example #9
0
    def announceGenerate(self):
        DistributedAvatarAI.announceGenerate(self)
        self.clearTrack()

        # Let's set the combo data task name and start the task.
        self.comboDataTaskName = self.uniqueName('clearComboData')
        taskMgr.add(self.clearComboData, self.comboDataTaskName)
        taskMgr.add(self.monitorHealth, self.uniqueName('monitorHealth'))

        self.stopPosHprBroadcast()
        self.stopAI()
 def delete(self):
     try:
         self.DistributedToonAI_deleted
     except:
         if type(self.backpack
                 ) != types.IntType and self.backpack is not None:
             self.backpack.cleanup()
             self.backpack = None
         self.DistributedToonAI_deleted = 1
         DistributedAvatarAI.delete(self)
         DistributedSmoothNodeAI.delete(self)
         self.questManager.cleanup()
         self.questManager = None
         self.tutDone = None
         self.token = None
         self.anim = None
         self.chat = None
         self.health = None
         self.damage = None
         self.height = None
         self.gender = None
         self.headtype = None
         self.head = None
         self.legtype = None
         self.torsotype = None
         self.hr = None
         self.hg = None
         self.hb = None
         self.tr = None
         self.tg = None
         self.tb = None
         self.lr = None
         self.lg = None
         self.lb = None
         self.shir = None
         self.shig = None
         self.shib = None
         self.shor = None
         self.shog = None
         self.shob = None
         self.shirt = None
         self.short = None
         self.sleeve = None
         self.isdying = None
         self.isdead = None
         self.toon_legs = None
         self.toon_torso = None
         self.toon_head = None
         self.portal = None
         self.book = None
         self.place = None
         self.attackers = None
         self.numGagSlots = None
     return
Example #11
0
 def delete(self):
     base.taskMgr.removeTasksMatching(self.uniqueName('DistributedPieTurretAI-scan'))
     base.taskMgr.removeTasksMatching(self.uniqueName('DistributedPieTurretAI-shootClosestTarget'))
     self.owner = None
     self.mgr = None
     self.targets = None
     self.shooting = None
     self.initialTargetHealth = None
     self.piesShot = None
     self.currentTarget = None
     self.deathEvent = None
     DistributedSmoothNodeAI.delete(self)
     DistributedAvatarAI.delete(self)
    def __init__(self, air):
        try:
            self.DistributedToonAI_initialized
            return
        except:
            self.DistributedToonAI_initialized = 1
        DistributedAvatarAI.__init__(self, air)
        ToonDNA.ToonDNA.__init__(self)
        self.avatarType = CIGlobals.Toon
        self.anim = "Happy"
        self.chat = ""
        self.health = 50
        self.height = 3
        self.gender = "boy"
        self.headtype = "dgm_skirt"
        self.head = "dog"
        self.legtype = "dgm"
        self.torsotype = "dgm_shorts"
        self.hr = 1
        self.hg = 1
        self.hb = 1
        self.tr = 1
        self.tg = 1
        self.tb = 1
        self.lr = 1
        self.lg = 1
        self.lb = 1
        self.shir = 1
        self.shig = 1
        self.shib = 1
        self.shor = 1
        self.shog = 1
        self.shob = 1
        self.shirt = "phase_3/maps/desat_shirt_1.mat"
        self.short = "phase_3/maps/desat_shorts_1.mat"
        self.sleeve = "phase_3/maps/desat_sleeve_1.mat"
        self.isdying = False
        self.isdead = False
        self.toon_legs = None
        self.toon_torso = None
        self.toon_head = None
        self.lookMode = 2  # LMOff

        self.activities = {
            ACT_DIE: 7.0,
            ACT_VICTORY_DANCE: 5.125,
            ACT_TOON_BOW: 4.0,
            ACT_JUMP: 2.5
        }

        return
Example #13
0
 def delete(self):
     self.torsoYaw = None
     self.version = None
     self.lastSpawnTime = None
     self.spawnIval = None
     self.doorTime = None
     self.doorState = None
     self.maxSuits = None
     self.numSuits = None
     self.lastAttackTime = None
     self.attackIval = None
     self.stopPosHprBroadcast()
     BaseNPCAI.delete(self)
     DistributedAvatarAI.delete(self)
Example #14
0
 def __init__(self, air):
     DistributedAvatarAI.__init__(self, air)
     DistributedSmoothNodeAI.__init__(self, air)
     self.owner = 0
     self.mgr = None
     
     # This is to optimize the turrets.
     self.targets = []
     self.shooting = False
     
     # This is for abandoning targets.
     self.initialTargetHealth = 0
     self.piesShot = 0
     self.currentTarget = None
     self.deathEvent = None
Example #15
0
    def announceGenerate(self):
        DistributedAvatarAI.announceGenerate(self)

        if not self.eyeLensNP:
            lens = PerspectiveLens()
            lens.setMinFov(180.0 / (4. / 3.))
            node = LensNode('toonEyes', lens)
            node.activateLens(0)
            self.eyeLensNP = self.attachNewNode(node)
            self.eyeLensNP.setZ(self.getHeight() - 0.5)
            self.eyeLensNP.setY(-1)

        self.setEyesOpenDuration()

        taskMgr.add(self.__eyesLookTask, self.taskName("eyesLookTask"))
 def __init__(self, air, charId):
     DistributedAvatarAI.__init__(self, air)
     self.fsm = ClassicFSM('DDCharAI',
                           [State('off', self.enterOff, self.exitOff),
                            State('neutral', self.enterNeutral, self.exitNeutral),
                            State('walking', self.enterWalking, self.exitWalking)],
                           'off', 'off')
     self.fsm.enterInitialState()
     self.charId = charId
     self.avatars = []
     self.inConvo = False
     self.chatsThisConvo = 0
     self.toonOfInterest = 0
     self.saidGoodbye = False
     self.currentPointLetter = None
     self.lastPointLetter = None
     self.talkEnabled = True
 def announceGenerate(self):
     DistributedAvatarAI.announceGenerate(self)
     DistributedEntityAI.announceGenerate(self)
     
     self.setPos(self.cEntity.getOrigin())
     self.setHpr(self.cEntity.getAngles() - (180, 0, 0))
     pos = self.getPos()
     hpr = self.getHpr()
     self.d_setPosHpr(pos[0], pos[1], pos[2], hpr[0], hpr[1], hpr[2])
     
     self.startPosHprBroadcast()
     
     self.startAI()
     
     if self.spawnflags & self.StartsAsleep:
         self.setNPCState(STATE_IDLE)
     else:
         self.setNPCState(STATE_ALERT)
Example #18
0
    def delete(self):
        BaseNPCAI.delete(self)

        self.stopPosHprBroadcast()
        self.clearTrack()
        self.stopStun()
        taskMgr.remove(self.uniqueName('__handleDeath'))
        taskMgr.remove(self.uniqueName('Resume Thinking'))
        taskMgr.remove(self.uniqueName('monitorHealth'))
        taskMgr.remove(self.comboDataTaskName)
        if self.tacticalSeq:
            self.tacticalSeq.pause()
            self.tacticalSeq = None
        self.suitPlan = None
        self.variant = None
        self.level = None
        self.animStateChangeEvent = None
        self.deathAnim = None
        self.deathTimeLeft = None
        self.comboData = None
        self.firstTimeDead = None
        self.clearComboDataTime = None
        self.showComboDamageTime = None
        self.showWeaknessBonusDamageTime = None
        self.stunned = None
        self.damagers = []

        self.DELETED = True
        del self.suitPlan
        del self.variant
        del self.level
        del self.animStateChangeEvent
        del self.track
        del self.deathAnim
        del self.deathTimeLeft
        del self.comboData
        del self.comboDataTaskName
        del self.clearComboDataTime
        del self.showComboDamageTime
        del self.showWeaknessBonusDamageTime
        del self.tacticalSeq
        del self.damagers
        del self.stunned
        DistributedAvatarAI.delete(self)
Example #19
0
    def __init__(self, air, dispatch):
        DistributedAvatarAI.__init__(self, air, dispatch)
        BaseNPCAI.__init__(self, dispatch)

        self.activities = {ACT_RANGE_ATTACK1: 2.5}

        self.died = False

        self.laserVec = [Vec3(0), Vec3(0)]

        self.schedules.update({
            "RANGE_ATTACK1":
            Schedule([
                Task_StopMoving(self),
                Task_StopAttack(self),
                Task_FaceTarget(self),
                Task_SetActivity(self, ACT_RANGE_ATTACK1),
                Task_Func(self.setupLaserVec),
                Task_Wait(0.635),
                Task_Func(self.fireLaser),
                Task_AwaitActivity(self)
            ],
                     interruptMask=COND_SCHEDULE_DONE | COND_TASK_FAILED)
        })

        self.patrolTime = 0.0
        self.patrolDur = 10.0

        self.surfaceProp = "metal"

        self.health = 25
        self.maxHealth = 25

        self.hatType = 0
        self.idealEyeColor = self.IdleEyeColor

        self.didFadeOut = False

        # height
        self.hitboxData[2] = 4.0
Example #20
0
    def __init__(self, air):
        try:
            self.DistributedToonAI_initialized
            return
        except:
            self.DistributedToonAI_initialized = 1
        DistributedAvatarAI.__init__(self, air)
        ToonDNA.ToonDNA.__init__(self)
        self.avatarType = CIGlobals.Toon
        self.anim = "Happy"

        self.lookMode = 2  # LMOff

        # Eyes stuff
        self.eyeLensNP = None
        self.eyeTarget = None
        self.targetIsNew = True
        self.lastEyeTarget = None
        self.eyeTargetLastPos = Point3(0)
        self.eyeTargetBoredTime = 0.0
        self.eyeTargetLastMove = 0
        self.eyeTargetTime = 0
        self.eyeStateTime = 0
        self.eyeState = ToonGlobals.EyeStateOpened
        self.eyesOpenDuration = 5
        self.eyeLookType = self.EyeLookType_Auto

        self.activities = {
            ACT_DIE: 7.0,
            ACT_VICTORY_DANCE: 5.125,
            ACT_TOON_BOW: 4.0,
            ACT_JUMP: 2.5,
            ACT_TOON_POINT: 10.0,
            ACT_TOON_PRESENT: 10.0,
            ACT_PRESS_BUTTON: 10.0,
            ACT_TOON_FALL: 2.5
        }

        return
Example #21
0
    def setHealth(self, health):
        prevHealth = self.health
        DistributedAvatarAI.setHealth(self, health)

        if not self.isDead() or self.isDead() and self.deathTimeLeft > 0:
            self.d_announceHealth(0, prevHealth - self.health)
 def delete(self):
     try:
         self.DistributedToonAI_deleted
     except:
         self.DistributedToonAI_deleted = 1
         DistributedAvatarAI.delete(self)
         self.avatarType = None
         self.anim = None
         self.chat = None
         self.height = None
         self.gender = None
         self.headtype = None
         self.head = None
         self.legtype = None
         self.torsotype = None
         self.hr = None
         self.hg = None
         self.hb = None
         self.tr = None
         self.tg = None
         self.tb = None
         self.lr = None
         self.lg = None
         self.lb = None
         self.shir = None
         self.shig = None
         self.shib = None
         self.shor = None
         self.shog = None
         self.shob = None
         self.shirt = None
         self.short = None
         self.sleeve = None
         self.isdying = None
         self.isdead = None
         self.toon_legs = None
         self.toon_torso = None
         self.toon_head = None
         del self.avatarType
         del self.anim
         del self.chat
         del self.height
         del self.gender
         del self.headtype
         del self.head
         del self.legtype
         del self.torsotype
         del self.hr
         del self.hg
         del self.hb
         del self.tr
         del self.tg
         del self.tb
         del self.lr
         del self.lg
         del self.lb
         del self.shir
         del self.shig
         del self.shib
         del self.shor
         del self.shog
         del self.shob
         del self.shirt
         del self.short
         del self.sleeve
         del self.isdying
         del self.isdead
         del self.toon_legs
         del self.toon_torso
         del self.toon_head
     return
Example #23
0
 def loadEntityValues(self):
     DistributedAvatarAI.loadEntityValues(self)
     self.hatType = self.getEntityValueInt("hat")
Example #24
0
 def setHealth(self, hp):
     DistributedAvatarAI.setHealth(self, hp)
     if hp < 1:
         self.getManager().sendUpdateToAvatarId(self.getOwner(), 'yourTurretIsDead', [])
         self.sendUpdate('die', [])
         Sequence(Wait(2.0), Func(self.getManager().killTurret, self.doId)).start()
 def announceGenerate(self):
     DistributedAvatarAI.announceGenerate(self)
     data = CHAR_DATA[self.charId]
     self.talkEnabled = data[4]
     self.fsm.request('neutral', [True])
 def __init__(self, air):
     try:
         self.DistributedToonAI_initialized
         return
     except:
         self.DistributedToonAI_initialized = 1
     DistributedAvatarAI.__init__(self, air)
     DistributedSmoothNodeAI.__init__(self, air)
     ToonDNA.ToonDNA.__init__(self)
     self.questManager = QuestManagerAI(self)
     self.avatarType = CIGlobals.Toon
     self.money = 0
     self.anim = "neutral"
     self.chat = ""
     self.health = 50
     self.damage = 0
     self.height = 3
     self.gender = "boy"
     self.headtype = "dgm_skirt"
     self.head = "dog"
     self.legtype = "dgm"
     self.torsotype = "dgm_shorts"
     self.hr = 1
     self.hg = 1
     self.hb = 1
     self.tr = 1
     self.tg = 1
     self.tb = 1
     self.lr = 1
     self.lg = 1
     self.lb = 1
     self.shir = 1
     self.shig = 1
     self.shib = 1
     self.shor = 1
     self.shog = 1
     self.shob = 1
     self.shirt = "phase_3/maps/desat_shirt_1.jpg"
     self.short = "phase_3/maps/desat_shorts_1.jpg"
     self.sleeve = "phase_3/maps/desat_sleeve_1.jpg"
     self.isdying = False
     self.isdead = False
     self.toon_legs = None
     self.toon_torso = None
     self.toon_head = None
     self.portal = None
     self.book = None
     self.token = -1
     self.ghost = 0
     self.attackers = []
     self.puInventory = []
     self.equippedPU = -1
     self.backpack = BackpackAI(self)
     self.quests = ""
     self.questHistory = []
     self.tier = -1
     self.friends = []
     self.tutDone = 0
     self.hoodsDiscovered = []
     self.teleportAccess = []
     self.lastHood = 0
     self.defaultShard = 0
     self.numGagSlots = 0
     self.trackExperience = dict(GagGlobals.DefaultTrackExperiences)
     return
 def announceGenerate(self):
     DistributedAvatarAI.announceGenerate(self)
     DistributedSmoothNodeAI.announceGenerate(self)
     if self.parentId != self.getDefaultShard():
         self.b_setDefaultShard(self.parentId)
Example #28
0
    def __init__(self, air):
        DistributedAvatarAI.__init__(self, air)
        BaseNPCAI.__init__(self)
        self.track = None
        self.suitPlan = 0
        self.variant = Variant.NORMAL
        self.level = 0
        self.animStateChangeEvent = SuitGlobals.animStateChangeEvent

        self.surfaceProp = "metal"

        # This is for handling death.
        self.deathAnim = None
        self.deathTimeLeft = 0
        self.deathTaskName = None

        # This is for handling combos.
        # Combo data stores an avId and gag type pair.
        # Avatar Ids are cheaper to store, so we use those.
        # comboDataTaskName is the name of the task that clears the data.
        self.comboData = {}
        self.comboDataTaskName = None
        self.clearComboDataTime = 3
        self.showComboDamageTime = 0.75

        # These variables are for handling gag weaknesses.
        self.showWeaknessBonusDamageTime = 0.50

        # The variable that stores the special sequence that handles tactical attacks.
        self.tacticalSeq = None

        self.allowHits = True
        self.firstTimeDead = True
        self.stunned = False

        self.damagers = []

        from src.coginvasion.attack.Attacks import ATTACK_CLIPONTIE, ATTACK_BOMB, ATTACK_PICKPOCKET, ATTACK_FIRED, ATTACK_HALF_WINDSOR
        from src.coginvasion.attack.Attacks import ATTACK_EVIL_EYE, ATTACK_RED_TAPE, ATTACK_SACKED, ATTACK_HARDBALL, ATTACK_MARKET_CRASH
        from src.coginvasion.attack.Attacks import ATTACK_BITE

        self.attackIds = [
            ATTACK_RED_TAPE, ATTACK_CLIPONTIE, ATTACK_BOMB, ATTACK_PICKPOCKET,
            ATTACK_FIRED, ATTACK_EVIL_EYE, ATTACK_SACKED, ATTACK_HARDBALL,
            ATTACK_MARKET_CRASH, ATTACK_HALF_WINDSOR, ATTACK_BITE
        ]

        self.activities = {
            ACT_WAKE_ANGRY: 0.564,
            ACT_SMALL_FLINCH: 2.25,
            ACT_DIE: 6.0,
            ACT_VICTORY_DANCE: 9.0,
            ACT_COG_FLY_DOWN: 6.834
        }

        self.schedules.update({
            "VICTORY_TAUNT":
            Schedule([
                Task_StopMoving(self),
                Task_StopAttack(self),
                Task_Speak(self, 0.5, [
                    "Aha, Toon! You thought you could get past me!",
                    "Caught tweakin, jit!",
                    "I told you it was my turn to play on the XBOX!"
                ]),
                Task_SetActivity(self, ACT_VICTORY_DANCE),
                Task_AwaitActivity(self)
            ],
                     interruptMask=COND_LIGHT_DAMAGE | COND_HEAVY_DAMAGE),
            "SUPA_FLY_IN_MOVE":
            Schedule([
                Task_StopMoving(self),
                Task_StopAttack(self),
                Task_GetFlyDownPath(self),
                Task_SetActivity(self, ACT_COG_FLY_DOWN),
                Task_RunPath(self),
                Task_AwaitMovement(self, changeYaw=False),
                Task_AwaitActivity(self),
                Task_Func(self.resetFwdSpeed)
            ],
                     interruptMask=COND_SCHEDULE_DONE | COND_TASK_FAILED)
        })
Example #29
0
 def takeDamage(self, dmgInfo):
     DistributedAvatarAI.takeDamage(self, dmgInfo)
     if self.isDead():
         self.cleanupPhysics()
Example #30
0
 def generate(self):
     DistributedAvatarAI.generate(self)