def __init__(self, species, gender, head, features, torso_size, legs_size, path=""): """ Args: species (str): "cat", "dog", "duck", "mouse", "pig", "rabbit", "bear", "horse" or "monkey". gender (str): "m" (male) or "f" (female). head (str): "n" (normal) or "l" (long). features (str): "n" (normal) or "l" (long). torso_size (str): "s" (small), "m" (medium) or "l" (long). legs_size (str): "s" (small), "m" (medium) or "l" (long). path (str, optional): The file path to the Toontown phase files. Defaults to Panda3D's search path. """ global MODEL_PATH if path: self.path = pfile.fromOsSpecific("%s/" % path).getFullpath() else: self.path = pfile.fromOsSpecific("%s/" % MODEL_PATH).getFullpath() self.species = species self.gender = gender self.dimensions = torso_size, legs_size self.__make_actor( species, gender, head, features, torso_size, legs_size ) Actor.__init__(self, self.parts, self.animation) self.__initialize_actor()
def __init__(self): Actor.__init__(self, "arena/elevator/elevator", {"open": "arena/elevator/elevatordooropenanim"}) self.setScale(1, 1, 1) self.setPos(50, -50, 0) self.reparentTo(render) self.loop("open")
def __init__(self, species, gender, head, features, torso_size, legs_size, path=""): """ Args: species (str): "cat", "dog", "duck", "mouse", "pig", "rabbit", "bear", "horse" or "monkey". gender (str): "m" (male) or "f" (female). head (str): "n" (normal) or "l" (long). features (str): "n" (normal) or "l" (long). torso_size (str): "s" (small), "m" (medium) or "l" (long). legs_size (str): "s" (small), "m" (medium) or "l" (long). path (str, optional): The file path to the Toontown phase files. Defaults to Panda3D's search path. """ global MODEL_PATH if path: self.path = pfile.fromOsSpecific("%s/" % path).getFullpath() else: self.path = pfile.fromOsSpecific("%s/" % MODEL_PATH).getFullpath() self.species = species self.gender = gender self.dimensions = torso_size, legs_size self.__make_actor(species, gender, head, features, torso_size, legs_size) Actor.__init__(self, self.parts, self.animation) self.__initialize_actor()
def __init__(self, mat=0): try: self.Avatar_initialized return except: self.Avatar_initialized = 1 ToonTalker.ToonTalker.__init__(self) Actor.__init__(self, None, None, None, flattenable=0, setFinal=1)#self.setColorOff() self.mat = mat self._name = '' self.chat = '' self.nametagNodePath = None self.__nameVisible = 1 self.nametag = NametagGroup() self.nametag.setAvatar(self) font = CIGlobals.getToonFont() self.nametag.setFont(font) self.nametag.setChatFont(font) self.nametag3d = self.attachNewNode('nametag3d') self.nametag3d.setTag('cam', 'nametag') self.setTwoSided(False) self.avatarType = None self.charName = None self._name = None self.tag = None self.height = 0 return
def __init__(self, defaultAnimation, hasShoes): try: Actor.__init__(self, {"head":"models/tt_a_chr_dgm_shorts_head_1000.bam", "torso":"models/tt_a_chr_dgm_shorts_torso_1000.bam", "legs":"models/tt_a_chr_dgm_shorts_legs_1000.bam"}, {"head":{"neutral":"models/anim/toonHead/tt_a_chr_dgm_shorts_head_neutral.bam", "run":"models/anim/toonHead/tt_a_chr_dgm_shorts_head_run.bam", "runjump":"models/anim/toonHead/tt_a_chr_dgm_shorts_head_leap_zhang.bam", "walk":"models/anim/toonHead/tt_a_chr_dgm_shorts_head_walk.bam", "jump":"models/anim/toonHead/tt_a_chr_dgm_shorts_head_jump-zhang.bam"}, "torso":{"neutral":"models/anim/toonTorso/tt_a_chr_dgm_shorts_torso_neutral.bam", "run":"models/anim/toonTorso/tt_a_chr_dgm_shorts_torso_run.bam", "runjump":"models/anim/toonTorso/tt_a_chr_dgm_shorts_torso_leap_zhang.bam", "walk":"models/anim/toonTorso/tt_a_chr_dgm_shorts_torso_walk.bam", "jump":"models/anim/toonTorso/tt_a_chr_dgm_shorts_torso_jump-zhang.bam"}, "legs":{"neutral":"models/anim/toonLegs/tt_a_chr_dgm_shorts_legs_neutral.bam", "run":"models/anim/toonLegs/tt_a_chr_dgm_shorts_legs_run.bam", "runjump":"models/anim/toonLegs/tt_a_chr_dgm_shorts_legs_leap_zhang.bam", "walk":"models/anim/toonLegs/tt_a_chr_dgm_shorts_legs_walk.bam", "jump":"models/anim/toonLegs/tt_a_chr_dgm_shorts_legs_jump-zhang.bam"}}) self.loop(defaultAnimation) self.attach("head", "torso", "def_head") self.attach("torso", "legs", "joint_hips") except IOError: Log.sendError("err") Actor.__init__(self, 'models/err.egg') if hasShoes is False: self.find("**/shoes").hide() self.find("**/boots_short").hide() self.find("**/boots_long").hide()
def __init__(self, physic_world, config=None): logging.info("INIT PLAYER...") logging.info("INIT FSM...") FSM.__init__(self, "FSM-Player") logging.info("INIT CONFIG...") Config.__init__(self) # additional initial configuration settings set by the outher application self.physic_world = physic_world logging.info("INIT PHYSICS...") Physics.__init__(self) logging.info("INIT CONTROLS...") Control.__init__(self) logging.info("INIT CAMERA...") Camera.__init__(self, self.cam_near_clip, self.cam_far_clip, self.cam_fov) logging.info("INIT ANIMATOR...") Animator.__init__(self) logging.info("INIT PLAYER DONE") # # STATES SETUP # self.on_ground_states = [ self.STATE_IDLE, self.STATE_IDLE_TO_WALK, self.STATE_WALK, self.STATE_WALK_TO_IDLE, self.STATE_PLANT ] # set the possible transition in the FSM self.defaultTransitions = { self.STATE_IDLE: [self.STATE_IDLE_TO_WALK, self.STATE_PLANT], self.STATE_IDLE_TO_WALK: [self.STATE_IDLE, self.STATE_WALK], self.STATE_WALK: [self.STATE_IDLE, self.STATE_WALK_TO_IDLE], self.STATE_WALK_TO_IDLE: [self.STATE_IDLE, self.STATE_WALK], self.STATE_PLANT: [self.STATE_IDLE], } # # ACTOR SETUP # Actor.__init__( self, self.model, { self.IDLE: self.anim_idle, self.WALK: self.anim_walk, self.PLANT: self.anim_plant, }) self.setBlend(frameBlend=self.enable_interpolation) alphaSettings = ColorBlendAttrib.make(ColorBlendAttrib.MAdd, ColorBlendAttrib.OIncomingAlpha, ColorBlendAttrib.OOne, (0, 0, 0, 0)) #self.setAttrib(alphaSettings) self.setBin("fixed", 15) self.setDepthWrite(False) # # CONTROLS SETUP # self.isDown = base.mouseWatcherNode.isButtonDown self.mainNode = self
def __init__(self, tlr): DistributedNode.DistributedNode.__init__(self, tlr) Actor.__init__(self, 'phase_5/models/char/tt_r_ara_ttc_trashcan', { 'hiccup': 'phase_5/models/char/tt_a_ara_ttc_trashcan_idleHiccup0' }) self.waitDuration = self.getDuration('hiccup') self.hiccupPlaying = False
def __init__(self, cr): Actor.__init__(self, "models/ralph", { "run": "models/ralph-run", "walk": "models/ralph-walk" }) DistributedSmoothNode.__init__(self, cr) self.setCacheable(1) self.setScale(.2)
def __init__(self, other=None): try: self.Avatar_initialized return except: self.Avatar_initialized = 1 Actor.__init__(self, None, None, other, flattenable=0, setFinal=1) self.setBlend(frameBlend=base.wantSmoothAnims) self.setLODAnimation(base.lodMaxRange, base.lodMinRange, base.lodDelayFactor) ShadowCaster.__init__(self) self.name = '' self.npcType = None self.__font = OTPGlobals.getInterfaceFont() self.soundChatBubble = None self.avatarType = '' self.nametagNodePath = None self.__nameVisible = 1 self.nametag = NametagGroup() self.nametag.setAvatar(self) interfaceFont = OTPGlobals.getInterfaceFont() self.nametag.setFont(interfaceFont) self.nametag.setChatFont(interfaceFont) self.nametag3d = self.attachNewNode('nametag3d') self.nametag3d.setTag('cam', 'nametag') self.nametag3d.setLightOff() if self.ManagesNametagAmbientLightChanged: self.acceptNametagAmbientLightChange() OTPRender.renderReflection(False, self.nametag3d, 'otp_avatar_nametag', None) self.getGeomNode().showThrough(OTPRender.ShadowCameraBitmask) self.nametag3d.hide(OTPRender.ShadowCameraBitmask) self.collTube = None self.battleTube = None self.scale = 1.0 self.nametagScale = 1.0 self.height = 0.0 self.battleTubeHeight = 0.0 self.battleTubeRadius = 0.0 self.style = None self.commonChatFlags = 0 self.understandable = 1 self.setPlayerType(NametagGlobals.CCNormal) self.ghostMode = 0 self.__chatParagraph = None self.__chatMessage = None self.__chatFlags = 0 self.__chatPageNumber = None self.__chatAddressee = None self.__chatDialogueList = [] self.__chatSet = 0 self.__chatLocal = 0 self.__chatQuitButton = False self.__currentDialogue = None self.whitelistChatFlags = 0
def __init__(self, other=None): self._name = '' try: self.Avatar_initialized return except: self.Avatar_initialized = 1 Actor.__init__(self, None, None, other, flattenable=0, setFinal=0) ShadowCaster.__init__(self) self.__font = OTPGlobals.getInterfaceFont() self.__speechFont = OTPGlobals.getInterfaceFont() self.soundChatBubble = None self.avatarType = '' self.nametagNodePath = None self.__nameVisible = 1 self.nametag = NametagGroup() self.nametag.setAvatar(self) self.nametag.setFont(OTPGlobals.getInterfaceFont()) self.nametag.setSpeechFont(OTPGlobals.getInterfaceFont()) self.nametag2dContents = Nametag.CName | Nametag.CSpeech self.nametag2dDist = Nametag.CName | Nametag.CSpeech self.nametag2dNormalContents = Nametag.CName | Nametag.CSpeech self.nametag3d = self.attachNewNode('nametag3d') self.nametag3d.setTag('cam', 'nametag') self.nametag3d.setLightOff() if self.ManagesNametagAmbientLightChanged: self.acceptNametagAmbientLightChange() OTPRender.renderReflection(False, self.nametag3d, 'otp_avatar_nametag', None) self.getGeomNode().showThrough(OTPRender.ShadowCameraBitmask) self.nametag3d.hide(OTPRender.ShadowCameraBitmask) self.collTube = None self.battleTube = None self.scale = 1.0 self.nametagScale = 1.0 self.height = 0.0 self.battleTubeHeight = 0.0 self.battleTubeRadius = 0.0 self.style = None self.commonChatFlags = 0 self.understandable = 1 self.setPlayerType(NametagGroup.CCNormal) self.ghostMode = 0 self.__chatParagraph = None self.__chatMessage = None self.__chatFlags = 0 self.__chatPageNumber = None self.__chatAddressee = None self.__chatDialogueList = [] self.__chatSet = 0 self.__chatLocal = 0 self.__currentDialogue = None self.whitelistChatFlags = 0 self.setBlend( frameBlend=config.GetBool('interpolate-animations', True)) return
def __init__(self, other=None): Actor.__init__(self, None, None, other, flattenable=0, setFinal=1) ShadowCaster.__init__(self) self.collTube = None self.scale = 1.0 self.height = 0.0 self.style = None self.hpText = None self.hpTextGenerator = TextNode('HpTextGenerator')
def __init__(self, modelName, animDict, defaultBlendTime, blendTimeDict = { }): Actor.__init__(self, modelName, animDict) self.enableBlend() self.uniqueCounter = BlendActor.counter BlendActor.counter += 1 self.defaultBlendTime = defaultBlendTime self.blendTimeDict = blendTimeDict self.blendInterval = None self.currentAnimation = None self.skeletonAnimationNames = animDict.keys()
def __init__(self, other = None): self.name = '' try: self.Avatar_initialized return except: self.Avatar_initialized = 1 Actor.__init__(self, None, None, other, flattenable=0, setFinal=0) ShadowCaster.__init__(self) self.__font = OTPGlobals.getInterfaceFont() self.__speechFont = OTPGlobals.getInterfaceFont() self.soundChatBubble = None self.avatarType = '' self.nametagNodePath = None self.__nameVisible = 1 self.nametag = NametagGroup() self.nametag.setAvatar(self) self.nametag.setFont(OTPGlobals.getInterfaceFont()) self.nametag.setSpeechFont(OTPGlobals.getInterfaceFont()) self.nametag2dContents = Nametag.CName | Nametag.CSpeech self.nametag2dDist = Nametag.CName | Nametag.CSpeech self.nametag2dNormalContents = Nametag.CName | Nametag.CSpeech self.nametag3d = self.attachNewNode('nametag3d') self.nametag3d.setTag('cam', 'nametag') self.nametag3d.setLightOff() if self.ManagesNametagAmbientLightChanged: self.acceptNametagAmbientLightChange() OTPRender.renderReflection(False, self.nametag3d, 'otp_avatar_nametag', None) self.getGeomNode().showThrough(OTPRender.ShadowCameraBitmask) self.nametag3d.hide(OTPRender.ShadowCameraBitmask) self.collTube = None self.battleTube = None self.scale = 1.0 self.nametagScale = 1.0 self.height = 0.0 self.battleTubeHeight = 0.0 self.battleTubeRadius = 0.0 self.style = None self.commonChatFlags = 0 self.understandable = 1 self.setPlayerType(NametagGroup.CCNormal) self.ghostMode = 0 self.__chatParagraph = None self.__chatMessage = None self.__chatFlags = 0 self.__chatPageNumber = None self.__chatAddressee = None self.__chatDialogueList = [] self.__chatSet = 0 self.__chatLocal = 0 self.__currentDialogue = None self.whitelistChatFlags = 0 self.wantAdminTag = True return
def __init__(self, type): model = self.locateModelFile(type) animMap = {} for anim in Cog.anims: animMap[anim] = self.locateAnimFile(anim, type) Actor.__init__(self, model, animMap) self.type = type self.walkPath = None self.speed = Cog.speedMap[self.type]
def __init__(self, app, model, start, end, shooter): Actor.__init__(self, model) self.app = app self.scene = app.scene self.start = start self.end = end self.shooter = shooter self.init_projectile_colors() self.reparentTo(self.scene) self.init_collision() self.make_shot_animation()
def __init__(self, name): Actor.__init__(self,PUSHY_PATH+"pushy.x", {"charge_start":PUSHY_PATH+"pushy_charge_start.x", "charge":PUSHY_PATH+"pushy_charge.x", "charge_release":PUSHY_PATH+"pushy_charge_release.x", "charge_fly":PUSHY_PATH+"pushy_charge_fly.x", "charge_hit":PUSHY_PATH+"pushy_charge_hit.x", "charge_miss":PUSHY_PATH+"pushy_charge_miss.x", "normal":PUSHY_PATH+"pushy_menu.x", "fall":PUSHY_PATH+"pushy_fall.x", "run":PUSHY_PATH+"pushy_run.x", "run_start":PUSHY_PATH+"pushy_run.x", "standup":PUSHY_PATH+"pushy_standup.x", "stop":PUSHY_PATH+"pushy_stop.x", "walk":PUSHY_PATH+"pushy_walk.x"}) self.name = name self.setName(name) self.health = 1.0 self.setScale(0.4) self.setPlayRate(0.05, "fall") self.setPlayRate(0.05, "charge_hit") self.setPlayRate(0.05, "charge_miss") self.setPlayRate(0.03, "standup") self.setPlayRate(0.05, "charge_release") self.setPlayRate(0.1, "run") self.flyingTime = 0 self.acFall=self.getAnimControl("fall") self.acStandup=self.getAnimControl("standup") self.acChargeStart=self.getAnimControl("charge_start") self.acCharge=self.getAnimControl("charge") self.acChargeRelease=self.getAnimControl("charge_release") self.acChargeFly=self.getAnimControl("charge_fly") self.acRunStart=self.getAnimControl("run_start") self.acRun=self.getAnimControl("run") # blender rotation fix self.find("**/+GeomNode").setH(180) self.rotationSpeed = 300 self.movementSpeed = 25 self.movementSpeedFlying = 50 self.movementSpeedFalling = 50 self.status = PLAYER_STATUS_NORMAL self.subStatus = 0 self.updateAnimation() #audio3d = Audio3DManager.Audio3DManager(base.sfxManagerList[0], camera) #mySound = audio3d.loadSfx('/audio/1.wav') self.chargeSound = base.loader.loadSfx(PUSHY_AUDIO_PATH+"Game Jam - Action - Charging 04.ogg") self.boringSound = base.loader.loadSfx(PUSHY_AUDIO_PATH+"Game Jam - Action - Boring 01.ogg") base.taskMgr.add(self.updateAnimTask, "update animation task")
def __init__(self,showbase,index,num_warlocks): # Load warlock model Actor.__init__(self,"media/warlock/warlock") # Reparent the model to render. self.reparentTo(render) # rotation between each warlock for even spacing rotation=360.0/num_warlocks # adjust rotation for this warlock rotation*=(index+1) # set its position 10*num_warlocks units from center and face warlock to center self.setPos(move_forwards(rotation,-10.0*num_warlocks)) self.setHpr(Vec3(rotation,0,0)) # destination (will be flag model or something eventually) self.destination=(self.getPos()) self.new_destination=False self.dest_node=showbase.loader.loadModel("media/warlock/dest/dest") # Reparent the model to render self.dest_node.reparentTo(render) self.dest_node.setScale(0.25) self.dest_node.setZ(-10) # initialise warlock spell stuff self.spell=0 self.spell_target=Vec3(0,0,0) self.casting=False # physics velocities (one for movement to destination, other for knock around caused by spells) self.dest_vel=Vec3(0,0,0) self.spell_vel=Vec3(0,0,0) # damage taken by warlock affects the friction applied to them, more damage == more slidey self.damage=1 # variable to track if warlock is on lava or still on arena self.on_lava=False # hit points of warlock self.hp=100.0 # collision sphere for collision detection #self.colSphere = CollisionSphere(0, 0, 2.5, 3) tube = CollisionTube(0, 0, 1.0, 0, 0, 3.0, 1.25) self.colNode = self.attachNewNode(CollisionNode('warlockTube'+str(index))) self.colNode.node().addSolid(tube) self.colNode.show() self.ray_str='downRay'+str(index) self.down = self.attachNewNode(CollisionNode(self.ray_str)) # for some reason when the ray is set to 0,0,1 it causes continuous collisions :S self.down.node().addSolid(CollisionRay(0.1, 0.1, 1.0, 0, 0, -1)) self.down.show()
def __init__(self, app, model, lives, name): Actor.__init__(self, model) # self.reparentTo(scene) self.app = app self.name = name self.scene = self.app.scene self.lives = lives self.prof_name = name self.init_collision() self.init_collision_plane() self.setup_life_bar()
def __init__(self, xPlayer, yPlayer, theta, time, ammonumber, id): Actor.__init__(self, "../model_territory/ammo2") self.X = xPlayer + cos(theta) * 1.5 self.Y = yPlayer + sin(theta) * 1.5 self.x_origine = self.X self.y_origine = self.Y self.radius = 0.5 self.id = id self.time = time #print(self.X,self.Y,time) self.r = 2 self.theta = theta self.number = ammonumber self.hit = False
def __init__(self, other=None): self.name = '' try: self.Avatar_initialized return except: self.Avatar_initialized = 1 Actor.__init__(self, None, None, other, flattenable=0, setFinal=1) self.__font = getInterfaceFont() self.avatarType = '' self.collTube = None self.scale = 1.0 self.height = 0.0 self.style = None
def __init__(self): Actor.__init__(self, None, None, None, flattenable=0, setFinal=1) FSM.__init__(self, 'ExperimentBlimp') self.loadModel('phase_4/models/events/blimp_mod.bam') self.loadAnims({'flying': 'phase_4/models/events/blimp_chan_flying.bam'}) self.television = ExperimentTelevision() self.television.reparentTo(self) self.flyTrack = Sequence( self.hprInterval(3.5, (140, 0, -5), blendType='easeInOut'), self.hprInterval(3.5, (140, 0, 5), blendType='easeInOut') )
def __init__(self): Actor.__init__(self, None, None, None, flattenable=0, setFinal=1) FSM.__init__(self, 'ExperimentBlimp') self.loadModel('phase_4/models/events/blimp_mod.bam') self.loadAnims( {'flying': 'phase_4/models/events/blimp_chan_flying.bam'}) self.television = ExperimentTelevision() self.television.reparentTo(self) self.flyTrack = Sequence( self.hprInterval(3.5, (140, 0, -5), blendType='easeInOut'), self.hprInterval(3.5, (140, 0, 5), blendType='easeInOut'))
def __init__(self): Actor.__init__(self, 'phase_5/models/props/birthday-cake-mod.bam') self.flames = [] numFlames = 6 for flameNum in xrange(numFlames): joint = self.controlJoint( None, "modelRoot", "joint_scale_flame{0}".format(flameNum + 1)) data = { 'joint': joint, 'lastPos': Point3(0, 0, 0), 'lastHpr': Vec3(0, 0, 0), 'idealHpr': joint.getHpr() } self.flames.append(data) taskMgr.add(self.__animateFlames, "animateFlamesTask")
def __init__(self, modelStr, driveStr, world): Actor.__init__(self, modelStr, {"drive": driveStr}) self.world = world self.setScale(0.005) self.setH(180) self.reparentTo(render) self.prevtime = 0 # some movement stats self.accel = 40.0 self.deccel = -40.0 self.bkwdsAccel = -10.0 self.speed = 0.0 self.maxSpeed = 100.0 self.maxBkwdsSpeed = -40.0 self.direction = Vehicle.STOPPED self.isTurning = False self.turnFactor = 4.0
def __init__(self, model, location, hp=50, team=3): Actor.__init__(self) #load model into world with specified health at location self.loadModel(model) self.renderer = base.render self.reparentTo(self.renderer) self.setPos(location) #collision stuff for bullets minimum, maximum = self.getTightBounds() # make sure all numbers are positive for best (any) results self.bounds = [abs(num) for num in (minimum - maximum)] self.width, self.length, self.height = self.bounds[0], self.bounds[ 1], self.bounds[2] #now specify health and team self.team = team self.health = hp
def __init__(self, cr, objectId, parent=render): Actor.__init__(self, 'phase_5/models/char/tt_r_ara_ttc_trashcan', {'hiccup':'phase_5/models/char/tt_a_ara_ttc_trashcan_idleHiccup0'}) self.waitDuration = self.getDuration('hiccup') self.persistenceFields = [] self.bothFields = ['requestHiccup'] self.reparentTo(parent) self.objectId = objectId self.doId = self.objectId self.triggerName = self.uniqueName('trigger') self.triggerEvent_enter = 'enter%s' % self.triggerName cs = CollisionSphere(0.0, 0.0, -1.4, 3.0) cs.setTangible(0) cn = CollisionNode(self.triggerName) cn.addSolid(cs) cn.setIntoCollideMask(OTPGlobals.WallBitmask) trigger = self.attachNewNode(cn) self.status = ESClosed self.accept(self.triggerEvent_enter, self.b_requestHiccup)
def __init__(self, mat = 0): self.mat = mat self.name = '' self.chat = '' try: self.Avatar_initialized return except: self.Avatar_initialized = 1 ToonTalker.ToonTalker.__init__(self) Actor.__init__(self, None, None, None, flattenable=0, setFinal=1) self.nameTag = None self.setTwoSided(False) self.avatarType = None self.charName = None self.name = None self.tag = None self.height = 0 return
def __init__(self, cr, objectId, parent=render): Actor.__init__(self, 'phase_5/models/char/tt_r_ara_ttc_trashcan', { 'hiccup': 'phase_5/models/char/tt_a_ara_ttc_trashcan_idleHiccup0' }) self.waitDuration = self.getDuration('hiccup') self.persistenceFields = [] self.bothFields = ['requestHiccup'] self.reparentTo(parent) self.objectId = objectId self.doId = self.objectId self.triggerName = self.uniqueName('trigger') self.triggerEvent_enter = 'enter%s' % self.triggerName cs = CollisionSphere(0.0, 0.0, -1.4, 3.0) cs.setTangible(0) cn = CollisionNode(self.triggerName) cn.addSolid(cs) cn.setIntoCollideMask(OTPGlobals.WallBitmask) trigger = self.attachNewNode(cn) self.status = ESClosed self.accept(self.triggerEvent_enter, self.b_requestHiccup)
def __init__(self, X, Y, Z, id, type): self.seconde_between_shoot = 0 self.distance_of_shoot = 0 self.min_damage = 0 self.max_damage = 0 self.id_gun = id self.id_player = -1 self.type = 0 self.collider = None if type == 1: Actor.__init__(self, "model_territory/AK-47") self.setPos(X, Y, Z) self.setHpr(0, 90, 0) self.type = 1 self.seconde_between_shoot = 0.15 self.distance_of_shoot = 30 self.min_damage = 10 self.max_damage = 17 self.setScale(0.8) self.collider = self.attach_new_node(CollisionNode('Gun/'+'AK-47'+"/"+str(self.id_gun))) self.collider.node().addSolid(CollisionSphere(0, 0, 0, 5)) self.collider.show() elif type == 2: Actor.__init__(self, "model_territory/Fusil_a_pompe") self.setPos(X, Y, Z) self.setHpr(0, 90, 0) self.type = 2 self.seconde_between_shoot = 0.8 self.distance_of_shoot = 10 self.min_damage = 25 self.max_damage = 40 self.collider = self.attach_new_node(CollisionNode('Gun/'+'Fusil_a_pompe'+"/"+str(self.id_gun))) self.collider.node().addSolid(CollisionSphere(0, 0, 0, 1)) self.collider.show() self.setScale(4) elif type == 3: Actor.__init__(self, "model_territory/ColtPython") self.setPos(X, Y, Z) self.setHpr(0, 90, 0) self.type = 3 self.seconde_between_shoot = 0.4 self.distance_of_shoot = 20 self.min_damage = 8 self.max_damage = 14 self.collider = self.attach_new_node(CollisionNode('Gun/'+'ColtPython'+"/"+str(self.id_gun))) self.collider.node().addSolid(CollisionSphere(0, 0, 0, 1)) self.collider.show() self.setScale(2) else: self.type = 4 self.seconde_between_shoot = 0.4 self.distance_of_shoot = 20 self.min_degat = 8 self.max_degat = 14
def __init__(self, modelStr, driveStr, world, plyr): Actor.__init__(self, modelStr, {"drive":driveStr}) self.world = world self.setH(180) self.reparentTo(render) self.prevtime = 0 #some movement stats self.accel = 30.0 self.brake = -200.0 self.deccel = -50.0 self.bkwdsAccel = -17.5 self.speed = 0.0 self.maxSpeed = 260.0 self.maxBkwdsSpeed = -40.0 self.direction = Vehicle.STOPPED self.isTurning = False self.blinkStart = 0 self.turnFactor = 2.0 self.loc = "" self.rampHprInterval = LerpFunc(self.rampInterval, fromData=0, toData=100, duration=RAMP_INTERVAL_DURATION, blendType='noBlend', extraArgs=[(0,0),(0,0)], name="rampInterval") self.health = 8 self.dead = False self.lastCollision = 0.0 self.speedClass = Vehicle.LOW #Deal with car sounds if plyr == "player": self.loadSounds() self.lowSound.play() self.totalGas = 150
def __init__(self, other = None): Actor.__init__(self, None, None, other, flattenable=0, setFinal=1) ShadowCaster.__init__(self) self.__font = OTPGlobals.getInterfaceFont() self.name = '' self.soundChatBubble = None self.avatarType = '' self.nametagNodePath = None self.__nameVisible = 1 self.nametag = NametagGroup() self.nametag.setAvatar(self) self.nametag.setFont(OTPGlobals.getInterfaceFont()) self.nametag.setSpeechFont(OTPGlobals.getInterfaceFont()) self.nametag2dContents = Nametag.CName | Nametag.CSpeech self.nametag2dDist = Nametag.CName | Nametag.CSpeech self.nametag2dNormalContents = Nametag.CName | Nametag.CSpeech self.nametag3d = self.attachNewNode('nametag3d') self.nametag3d.setTag('cam', 'nametag') self.nametag3d.setLightOff() self.getGeomNode().showThrough(OTPRender.ShadowCameraBitmask) self.nametag3d.hide(OTPRender.ShadowCameraBitmask) self.collTube = None self.scale = 1.0 self.height = 0.0 self.style = None self.understandable = 1 self.setPlayerType(NametagGroup.CCNormal) self.ghostMode = 0 self.__chatParagraph = None self.__chatMessage = None self.__chatFlags = 0 self.__chatPageNumber = None self.__chatAddressee = None self.__chatDialogueList = [] self.__chatSet = 0 self.__chatLocal = 0 self.__currentDialogue = None self.wantAdminTag = True
def __init__(self, X, Y, Z, id): #sys.path.append('/Users/anthonnyolime/Git-Projet/2020_5A_IABD_DRL_Gym/environments/battle_royale/game') Actor.__init__(self, "model_territory/Android") self.setPos(X, Y, Z) self.X_decision = 0 self.Y_decision = 0 self.shoot_decision = 0 self.shoot_or_not_decision = 0 self.setScale(2) self.text = None self.textstr = None self.max_distance = 50 #print(self.getTightBounds()) self.shoot = [] self.shootTimeDelay = 0.5 # AK-45 : 0.15 | 30 # coltPython : 0.4 | 20 # fusil_a_pompe : 0.8 | 10 # main nue : 0.5 | 3 self.time_delay_pick = 10 self.time_pick = 0 self.guntype = 0 self.has_a_gun = False self.gun = None self.player_hit_me = -1 self.shootTimeDelayNow = 0 self.id = id # self.health = 50 self.health = 25 self.ammonumber = 0 self.ammo_hit = 0 self.ammo_miss = 0 self.kill = 0 self.score = 0 self.discovery = []
def __init__(self, app, model, rightArm=None, leftArm=None, leftArmBook=None, lives=9): Actor.__init__(self, model) self.app = app self.scene = app.scene self.lives = lives self.last_x = 0 self.last_y = 0 # self.charged = True self.block = False self.setHpr(180, 0, 0) if leftArm: self.leftArm = self.app.loader.loadModel(leftArm) if rightArm: self.rightArm = self.app.loader.loadModel(rightArm) if leftArmBook: self.leftArmBook = self.app.loader.loadModel(leftArmBook) self.set_up_arms() self.init_collision() self.load_HUD() self.init_mouse_control_event()
def __init__(self, other=None): """ Create the toon, suit, or char specified by the dna array """ self.name = "" # name is used in debugPrint. assert self.debugPrint("Avatar()") try: self.Avatar_initialized return except: self.Avatar_initialized = 1 # create an empty actor to add parts to Actor.__init__(self, None, None, other, flattenable = 0, setFinal = 1) ShadowCaster.__init__(self) # The default font. self.__font = OTPGlobals.getInterfaceFont() self.soundChatBubble = None # Holds Type of Avatar self.avatarType = "" self.nametagNodePath = None # Set up a nametag (actually, a group of nametags, # including a Nametag2d and a Nametag3d) for the avatar. # The nametag won't be visible until it is managed, which # will happen during addActive(). self.__nameVisible = 1 self.nametag = NametagGroup() self.nametag.setAvatar(self) self.nametag.setFont(OTPGlobals.getInterfaceFont()) self.nametag2dContents = Nametag.CName | Nametag.CSpeech # nametag2dDist is changed only by DistributedAvatar. self.nametag2dDist = Nametag.CName | Nametag.CSpeech self.nametag2dNormalContents = Nametag.CName | Nametag.CSpeech self.nametag3d = self.attachNewNode('nametag3d') self.nametag3d.setTag('cam', 'nametag') self.nametag3d.setLightOff() #Accept ambient lighting changes if self.ManagesNametagAmbientLightChanged: self.acceptNametagAmbientLightChange() # do not display in reflections OTPRender.renderReflection (False, self.nametag3d, 'otp_avatar_nametag', None) # But do show in shadows, except for the nametag. self.getGeomNode().showThrough(OTPRender.ShadowCameraBitmask) self.nametag3d.hide(OTPRender.ShadowCameraBitmask) self.collTube = None self.battleTube = None # set some initial values self.scale = 1.0 self.nametagScale = 1.0 self.height = 0.0 self.battleTubeHeight = 0.0 self.battleTubeRadius = 0.0 self.style = None # commonChatFlags is a bitmask that may include the CommonChat # and SuperChat bits. self.commonChatFlags = 0 # This is either CCNonPlayer, CCSuit, or CCNormal, # according to whether there's a human behind the avatar # or not. This determines the color nametag that is # assigned, as well as whether chat messages from this # avatar will be garbled. self.understandable = 1 self.setPlayerType(NametagGroup.CCNormal) self.ghostMode = 0 # Page chat private vars self.__chatParagraph = None self.__chatMessage = None self.__chatFlags = 0 self.__chatPageNumber = None self.__chatAddressee = None self.__chatDialogueList = [] self.__chatSet = 0 self.__chatLocal = 0 # Record current dialogue so it can be interrupted the # next time the avatar talks self.__currentDialogue = None # since whiteListChatFlags is not a required field, init it just in case self.whitelistChatFlags = 0
def __init__(self, models = None, anims = None, damages = false): Actor.__init__(self, models, anims)
def __init__(self, model: str, base: ShowBase, pos: tuple, physics=True): ''' constructor for entity. attaches model to calling instance renderer also stores size definitions and creates basic collision object ''' Actor.__init__(self) DEFAULT_HEALTH = 50 #reference base for later self.base = base # set health self.health = DEFAULT_HEALTH self.damagedSound = base.loader.loadSfx("sounds/oof.ogg") # speed self.speed = 10 self.turnSpeed = 5 # gravity -- is touching ground? self.isGrounded = False # creates actor object using constructor and parents to passed renderer self.loadModel(model) self.renderer = base.render self.reparentTo(self.renderer) # put at specified location self.setPos(pos) # store dimensions for later # https://discourse.panda3d.org/t/getting-the-height-width-and-length-of-models-solved/6504 # Post describes the output of the Nodepath class's getTightBounds() method. Using this # I am able to get an approximation of the dimensions of an object in the global coordinate space minimum, maximum = self.getTightBounds() # make sure all numbers are positive for best (any) results self.bounds = [abs(num) for num in (minimum - maximum)] self.width, self.length, self.height = self.bounds[0], self.bounds[ 1], self.bounds[2] # COLLISION PROPERTIES # create collision ray that is height of model pointing down (will detect ground collisions) if physics: self.groundRay = CollisionRay() self.groundRay.setOrigin(0, 0, 1000) self.groundRay.setDirection(0, 0, -1) self.groundCol = CollisionNode('groundRay') self.groundCol.addSolid(self.groundRay) self.groundCol.setFromCollideMask(BitMask32.bit(0)) self.groundCol.setIntoCollideMask(BitMask32.allOff()) self.groundColNode = self.attachNewNode(self.groundCol) base.cTrav.addCollider(self.groundColNode, base.groundHandler) #and another one for everything else self.mainCol = CollisionNode('actorCollision' + str(id(self))) # create collision sphere as solid for this collision node self.mainCol.addSolid( CollisionSphere(0, 0, self.height / 2, self.height / 2)) # specify valid collisions for collision node self.mainCol.setFromCollideMask(CollideMask.bit(0)) self.mainCol.setIntoCollideMask(CollideMask.bit( 1)) # accepts incoming objects with collideMask bit(1) # attach collision node to actor self.cNode = self.attachNewNode(self.mainCol) # show #self.cNode.show() # make instance collision traverser aware of this collision node, tell it how to handle (with pusher) base.cTrav.addCollider(self.cNode, base.pusher) # add collision to pusher collision handler; tell pusher which node to associate with which actor IOT push base.pusher.addCollider(self.cNode, self, base.drive.node()) # add to base.entities (since all allies/enemies created through this constructor, makes sense base.entities.append(self) # add as client of entity collision handler # base.cTrav.addCollider(self.cNode,base.entityCollisionHandler) #add to cleanup for deletion later base.cleanup.append(self) #store reference to self #https://discourse.panda3d.org/t/inheriting-from-nodepath/10886/4 #post describes how to set up a reference from nodepath to itself to retrieve custom properties #I use python tags to distinguish collision volume owners self.mainCol.setPythonTag("owner", self)
def __init__(self, physic_world, config=None): logging.info("INIT PLAYER...") logging.info("INIT FSM...") FSM.__init__(self, "FSM-Player") logging.info("INIT CONFIG...") Config.__init__(self) # additional initial configuration settings set by the outher application self.physic_world = physic_world logging.info("INIT PHYSICS...") Physics.__init__(self) logging.info("INIT CONTROLS...") Control.__init__(self) logging.info("INIT CAMERA...") Camera.__init__( self, self.cam_near_clip, self.cam_far_clip, self.cam_fov) logging.info("INIT ANIMATOR...") Animator.__init__(self) logging.info("INIT PLAYER DONE") # # STATES SETUP # self.on_ground_states = [ self.STATE_IDLE, self.STATE_IDLE_TO_WALK, self.STATE_WALK, self.STATE_WALK_TO_IDLE, self.STATE_PLANT] # set the possible transition in the FSM self.defaultTransitions = { self.STATE_IDLE: [self.STATE_IDLE_TO_WALK, self.STATE_PLANT], self.STATE_IDLE_TO_WALK: [self.STATE_IDLE, self.STATE_WALK], self.STATE_WALK: [self.STATE_IDLE, self.STATE_WALK_TO_IDLE], self.STATE_WALK_TO_IDLE: [self.STATE_IDLE, self.STATE_WALK], self.STATE_PLANT: [self.STATE_IDLE], } # # ACTOR SETUP # Actor.__init__( self, self.model, { self.IDLE: self.anim_idle, self.WALK: self.anim_walk, self.PLANT: self.anim_plant, }) self.setBlend(frameBlend=self.enable_interpolation) alphaSettings = ColorBlendAttrib.make( ColorBlendAttrib.MAdd, ColorBlendAttrib.OIncomingAlpha, ColorBlendAttrib.OOne, (0, 0, 0, 0)) #self.setAttrib(alphaSettings) self.setBin("fixed", 15) self.setDepthWrite(False) # # CONTROLS SETUP # self.isDown = base.mouseWatcherNode.isButtonDown self.mainNode = self
def __init__(self, mat=0): try: self.Avatar_initialized return except: self.Avatar_initialized = 1 ToonTalker.ToonTalker.__init__(self) #BasePhysicsObject.__init__(self) AvatarShared.__init__(self) Actor.__init__(self, None, None, None, flattenable=0, setFinal=1) # All avatars should be ambient boosted to help them stand out more in BSP levels. self.setAmbientBoost() self.shapeGroup = CIGlobals.WallGroup | CIGlobals.CharacterGroup #self.getGeomNode().showThrough(CIGlobals.ShadowCameraBitmask) self.usedAnims = [] self.moveAnimProperties = {} self.mat = mat self.chat = '' self.nametagNodePath = None self.__nameVisible = 1 self.nametag = NametagGroup() self.nametag.setAvatar(self) font = CIGlobals.getToonFont() self.nametag.setFont(font) self.nametag.setChatFont(font) self.nametag3d = self.attachNewNode('nametag3d') self.nametag3d.setTag('cam', 'nametag') self.setTwoSided(False) self.forwardSpeed = 0.0 self.rotateSpeed = 0.0 self.strafeSpeed = 0.0 self.currentSpeed = 0.0 self.standWalkRunReverse = None self.currentMoveAction = None self.enableBlend() self.showNametagInMargins = True self.avatarType = None self.charName = None self.tag = None self.splashEffect = None self.splashSound = None self.shadow = None self.prevPos = Point3(0) self.wake = None self.lastWakeTime = 0.0 self.thoughtInProg = False self.shadowFloorToggle = False self.avatarFloorToggle = False self.floorTask = taskMgr.add(self.__keepOnFloorTask, "Avatar.keepOnFloor", sort=30) self.ragdoll = None self.ragdollMode = False self.healthLabel = None self.healthLabelTrack = None self.dmgFadeIval = None self.forcedTorsoAnim = None self.lastForcedTorsoAnim = None self.activityTrack = None self.wasDoingActivity = False self.fadeTrack = None self.playedAnims = None self.chatSoundTable = {} return
def __init__(self, models = None, anims = None, sphereString = "**/CollisionSphere", game = None, xStart = 0, yStart = 0, zStart = 0, radius = 3): Actor.__init__(self, models, anims) self.game = game self.health = 10 self.heightOffset = 3 #set up the position self.setPos(xStart, yStart, zStart) self.prevPosition = self.getPos() #self.lastPosition = Point3() self.vel = Vec3() self.accel = Vec3(0, 0, -Unit.gravity) #define the position that will be treated as the center of the map self.wCenter = Point3(0, 0, 0) #the radius of the sphere around this self.radius = 3.5 #the base damage this unit deals upon collision self.collisionAttackPower = 2.5 #set up Panda's collisions #first the pusher cSphere = CollisionSphere((0, 0, 1), 2) cNode = CollisionNode("unit") cNode.addSolid(cSphere) cNode.setIntoCollideMask(BitMask32(PLAYER_ENEMY_OBJECTS)) cNode.setFromCollideMask(BitMask32(PLAYER_ENEMY_OBJECTS)) self.collisionNodePath = self.attachNewNode(cNode) #self.collisionNodePath.show() #set pattern for event sent on collision # "%in" is substituted with the name of the into object, "%fn" is substituted with the name of the from object #do the collision pusher self.collisionPusher = CollisionHandlerPusher() self.collisionPusher.addCollider(self.collisionNodePath, self) self.collisionPusher.addInPattern("%fn-into-%in") self.collisionPusher.addOutPattern("fn-out-%in") game.cTrav.addCollider(self.collisionNodePath, self.collisionPusher) #check for colllisions with the ground self.groundRay = CollisionRay() self.groundRay.setOrigin(0, 0, 4000) self.groundRay.setDirection(0, 0, -1) self.groundCol = CollisionNode('unitRay') self.groundCol.addSolid(self.groundRay) self.groundCol.setFromCollideMask(BitMask32(TERRAIN_RAY_MASK)) self.groundCol.setIntoCollideMask(BitMask32.allOff()) self.groundColNode = self.attachNewNode(self.groundCol) self.groundHandler = CollisionHandlerQueue() game.cTrav.addCollider(self.groundColNode, self.groundHandler) #can be thought of as the inverse of the unit's mass self.accelMultiplier = 45 self.friction = 1.7 self.disableFriction = False self.nodePath = None self.shootable = True #finally set the python tag self.setPythonTag("unit", self)
def __init__(self): Actor.__init__(self, "models/man") self.setScale(0.5, 0.5, 0.5)
def __init__(self, other=None): Actor.__init__(self, None, None, other, flattenable=0, setFinal=1) ToonHead.__init__(self) self.scale = 1 self.height = 0.0 self.style = None
def __init__(self): Actor.__init__(self,"arena/elevator/elevator",{"open":"arena/elevator/elevatordooropenanim"}) self.setScale(1,1,1) self.setPos(50,-50,0) self.reparentTo(render) self.loop("open")