def __init__(self, mainRef, attributes): print("Enemy instantiated") Unit.__init__(self) FSM.__init__(self, 'playerFSM') self._mainRef = mainRef self._playerRef = mainRef.player self._AIworldRef = mainRef.AIworld self._enemyListRef = mainRef.enemyList self._ddaHandlerRef = mainRef.DDAHandler self._stateHandlerRef = mainRef.stateHandler self._scenarioHandlerRef = mainRef.scenarioHandler #self.topEnemyNode = mainRef.mainNode.attachNewNode('topEnemyNode') self.initEnemyNode(mainRef.mainNode) utils.enemyDictionary[self.enemyNode.getName()] = self self.loadEnemyModel(attributes.modelName) self.initAttributes(attributes) self.initEnemyAi() self.initEnemyDDA() self.initEnemyCollisionHandlers() self.initEnemyCollisionSolids() #self.request('Idle') self.request('Disabled') # Start enemy updater task self.enemyUpdaterTask = taskMgr.add(self.enemyUpdater, 'enemyUpdaterTask')
def __init__(self, mainObj, position, yon=4, layer=0, attrDict={}): self.type = 'Kurt' Unit.__init__(self, mainObj, position, yon, attrDict) self.image = self.changeImage( 'Kurt', yon) # Oyunun başında ilk yüklenen unit resim dosyasi self.rect = self.image.get_rect() self.rect.topleft = position self.layer = layer # LayeredUpdates grubu için gerekiyor self.colRect = copy(Kurt.colRect[self.yon]) self.colRect.topleft = (self.colRect.topleft[0] + self.rect.topleft[0], self.colRect.topleft[1] + self.rect.topleft[1]) # çarpışmalarda kullanılan noktalar self.colPoints = None self.tolerans = 0 self.speed = 4 if self.player.type == Player.human_player: self.ai = KurtFSM(self, human=True) else: self.ai = KurtFSM(self) # unit'in gerçek pozisyonunu (reel sayılarla) tutar. rect'e atılırken int'e dönüştürülür. self.yer = Vector2(*self.colRect.center)
def __init__(self, player, sig, model, skeleton, animations, inventory): ''' Constructor ''' Unit.__init__(player, sig, numControllers = 1) self.player = player self.enabled = False
def __init__(self, mainObj, position, yon=4, layer=0, attrDict={}): self.type = 'Kurt' Unit.__init__(self, mainObj, position, yon, attrDict) self.image = self.changeImage('Kurt', yon) # Oyunun başında ilk yüklenen unit resim dosyasi self.rect = self.image.get_rect() self.rect.topleft = position self.layer = layer # LayeredUpdates grubu için gerekiyor self.colRect = copy(Kurt.colRect[self.yon]) self.colRect.topleft = (self.colRect.topleft[0] + self.rect.topleft[0], self.colRect.topleft[1] + self.rect.topleft[1]) # çarpışmalarda kullanılan noktalar self.colPoints = None self.tolerans = 0 self.speed = 4 if self.player.type == Player.human_player: self.ai = KurtFSM(self, human=True) else: self.ai = KurtFSM(self) # unit'in gerçek pozisyonunu (reel sayılarla) tutar. rect'e atılırken int'e dönüştürülür. self.yer = Vector2(*self.colRect.center)
def __init__(self, name='Werewolf', hit_points_limit=120): Unit.__init__(self, name, hit_points_limit) self.weapon = Sword(self) self.current_state.title = 'Werewolf' self.current_state.is_werewolf = True self.current_state.is_infected = True self.alt_weapon = Claws(self)
def __init__(self, constraint, x=0, y=0, direction=(1, 0), kind=0): Unit.__init__(self, constraint, x, y, direction, 160, 65) if kind: self.kind = 'lion' self.health = 200 else: self.kind = 'blue' self.health = 100
def __init__(self, models = None, anims = None, sphereString = None, game = None, xStart = 0, yStart = 0, zStart = 0): Unit.__init__(self, models, anims, sphereString, game, xStart, yStart, zStart) #set up sounds self.deathSound = game.loader.loadSfx(SFX_PATH + "enemy_death.wav") self.randomMovement = 0 self.randomMovementMax = 30 * 7 self.minRandomVel = 1000 self.maxRandomVel = 2000
def __init__(self, name, title, health, mana, mana_regen): self.name = name self.title = title self.mana_regen = mana_regen Unit.__init__(self, health, mana, name) self.phisical_damage = 0 self.magic_damage = 0 self.max_equiped_weapons = 0 self.max_learned_spells = 0
def __init__(self, team, sig, model, numControllers, keyinput): ''' Constructor ''' self.input = keyinput self.model = loader.loadModel(model) tankNode = render.attachNewNode(ActorNode("tank-physics")) tankNode.detachNode() self.tankNode = tankNode actorNode = tankNode.node() base.physicsMgr.attachPhysicalNode(actorNode) actorNode.getPhysicsObject().setMass(1000) fromObject = tankNode.attachNewNode(CollisionNode('tank-coll')) fromObject.node().addSolid(CollisionSphere(0, 0, 0, 1)) self.model.reparentTo(tankNode) pusher = PhysicsCollisionHandler() pusher.addCollider(fromObject,tankNode) base.cTrav.addCollider(fromObject, pusher) fromObject.show() Unit.__init__(self, sig, numControllers) self.enabled = False self.camera = VehicleCamera(self.tankNode, Vec3(0,-10,5)) self.rotation = Rotation(self.tankNode, self.camera.camNode) self.engineFN=ForceNode('tank-hover-engine-front-left') self.engineFNP=tankNode.attachNewNode(self.engineFN) self.engineNodes = [NodePath("front-left-engine") , NodePath("front-right-engine"), NodePath("back-left-engine") , NodePath("back-right-engine") ] for i in range(0,4): self.engineNodes[i].reparentTo(tankNode) self.engineNodes[i].setPos(tankNode, ENGINELIST[i]) blah = loader.loadModel(model) blah.reparentTo(self.engineNodes[i]) blah.setScale(0.1) self.linearForce = None self.rotateForce = None self.movement = Movement(tankNode) self.movement.enable()
def __init__(self, constraint, x=0, y=0, direction=(1, 0), size=0): radius = (size * 15 + 41) / 2 Unit.__init__(self, constraint, x, y, direction, 80, radius) SinkingItem.__init__(self, constraint, x, y, 80, radius) self.hungry = False self.growth = 0 # Fish size: 0 - small, 1 - normal, 2 - big self.size = size self.last_fed = int(time()) self.grow_time = int(time()) self.drop_coin = False # Prevents multiple coin drops in the same second. self.coin_drop_time = time()
def __init__(self, team, sig, model, numControllers, keyinput): ''' Constructor ''' self.input = keyinput self.model = loader.loadModel(model) tankNode = render.attachNewNode(ActorNode("tank-physics")) tankNode.detachNode() self.tankNode = tankNode actorNode = tankNode.node() base.physicsMgr.attachPhysicalNode(actorNode) actorNode.getPhysicsObject().setMass(1000) fromObject = tankNode.attachNewNode(CollisionNode('tank-coll')) fromObject.node().addSolid(CollisionSphere(0, 0, 0, 1)) self.model.reparentTo(tankNode) pusher = PhysicsCollisionHandler() pusher.addCollider(fromObject,tankNode) base.cTrav.addCollider(fromObject, pusher) fromObject.show() Unit.__init__(self, sig, numControllers) self.enabled = False self.camera = VehicleCamera(self.tankNode, Vec3(0,-10,5)) self.rotation = Rotation(self.tankNode, self.camera.camNode) self.engineFN=ForceNode('tank-engine') self.engineFNP=tankNode.attachNewNode(self.engineFN) self.upForce=LinearVectorForce(0,0,20000) self.upForce.setMassDependent(1) self.engineFN.addForce(self.upForce) base.physicsMgr.addLinearForce(self.upForce)
def __init__(self, mainRef): print("Player instantiated") Unit.__init__(self) FSM.__init__(self, 'playerFSM') self._hudRef = None self._mainRef = mainRef self._enemyListRef = mainRef.enemyList self._ddaHandlerRef = mainRef.DDAHandler self._mapHandlerRef = mainRef.mapHandler self._stateHandlerRef = mainRef.stateHandler self._scenarioHandlerRef = mainRef.scenarioHandler self.playerNode = mainRef.mainNode.attachNewNode('playerNode') self.initPlayerAttributes() self.initPlayerModel() self.initPlayerCamera() self.initPlayerAbilities() self.initPlayerCollisionHandlers() self.initPlayerCollisionSolids() self.initPlayerDDA() # Start mouse picking and movement self.mouseHandler = utils.MouseHandler(self) # Start player update task playerUpdateTask = taskMgr.add(self.playerUpdate, 'playerUpdateTask') # Initialize player FSM state self.request('Idle') DO = DirectObject() DO.accept('shift-mouse1', self.onShiftDown) DO.accept('shift-up', self.onShiftUp) self._shiftButtonDown = False
def __init__(self, uid, pos, images): Unit.__init__(self, pos, images, 100, 10, 10, uid, SGOP, GUAR, 10)
def __init__(self, xmldoc): Unit.__init__(self) # This is a combat vehicle self.type = "CV" # Get top-level structure data for cveh in xmldoc.getElementsByTagName('combatvehicle'): self.model = cveh.attributes["model"].value self.name = cveh.attributes["name"].value self.motive = cveh.attributes["motive"].value self.omni = cveh.attributes["omni"].value self.weight = int(cveh.attributes["tons"].value) # Get BV. Should give prime variant BV for Omni-vehicles # get first instance only to avoid problems with Omni-vehicles self.batt_val = int(get_child_data(cveh, 'battle_value')) # Motive for mot in cveh.getElementsByTagName('motive'): self.mot_type = mot.attributes["type"].value self.cruise = int(mot.attributes["cruise"].value) self.turret = mot.attributes["turret"].value # Get Cost. cost = float(get_child_data(cveh, 'cost')) # Get production era self.prod_era = int(get_child_data(cveh, 'productionera')) # Get techbase (IS, Clan) # get first instance only to avoid problems with Omni-vehicles self.techbase = get_child_data(cveh, 'techbase') # Get year self.year = int(get_child_data(cveh, 'year')) # Sanity check for year year_era_test(self.year, self.prod_era, self.name + " " + self.model) if (self.year < 2470): print self.name, self.model print "Combat Vehicles not available before 2470!" sys.exit(1) if (self.year < 2854 and self.omni == "TRUE"): print self.name, self.model print "OmniVehicles not available before 2854!" sys.exit(1) ### Components starts here ### self.structure = VehicleStructure(get_child(cveh, 'structure'), self.weight, self.mot_type, self.turret) self.engine = Engine(get_child(cveh, 'engine'), self) self.lift = LiftEquipment(self.weight, self.mot_type) if self.engine.etype == "No Engine": self.control = ControlSystems(0.0) else: self.control = ControlSystems(self.weight) self.armor = VehicleArmor(get_child(cveh, 'armor'), self.weight) ### Loadout stuff starts here ### # Get baseloadout blo = cveh.getElementsByTagName('baseloadout')[0] # Construct current loadout, empty name for base loadout self.load = Baseloadout(blo, self, self.batt_val, self.prod_era, cost) # Get omni loadouts self.loads = [] for load in cveh.getElementsByTagName('loadout'): # Construct current loadout current = Loadout(load, self.load, self) self.loads.append(current)
def __init__(self, uid, pos, images): Unit.__init__(self, pos, images, 50, 0, 0, uid, CBOP, AERO, 10)
def __init__(self, name='Rogue', hit_points_limit=90): Unit.__init__(self, name, hit_points_limit) self.weapon = Dagger(self)
def __init__(self, uid, pos, images): Unit.__init__(self, pos, images, 400, 15, 15, uid, CPCB, CORB, 10)
def __init__ (self, uid) : Unit.__init__ (self, uid)
def __init__(self): WEAPONS = [ShortSword(self), BlackBlade(self)] Unit.__init__(self, "Evil Spirit", HP = 75, ATK = 12, DEF = 12, MAG = 0, RES = 0, ACC = 8, EVA = 8, SPD = 8, weapons = WEAPONS) return
def __init__(self, uid): Unit.__init__(self, uid)
def __init__(self, uid, pos, images): Unit.__init__(self, pos, images, 300, 25, 25, uid, CPNV, MISI, 10)
def __init__(self, x, y, sprite, window, health, collisonradius, scale): Unit.__init__(self, x, y, sprite, window, health, collisonradius, scale) # new movment algorithm self.last = random.randint(0, 3)
def __init__(self, name='Vampire', hit_points_limit=120): Unit.__init__(self, name, hit_points_limit) self.weapon = Fangs(self) self.vampire_state() self.current_state.name = name
def __init__(self, xmldoc): Unit.__init__(self) # This is a mech self.type = "BM" # Set some data to zero that sometimes will not get set otherwise self.multi = Multi() # Get top-level structure data for mmech in xmldoc.getElementsByTagName('mech'): self.model = mmech.attributes["model"].value self.name = mmech.attributes["name"].value self.omni = mmech.attributes["omnimech"].value self.weight = int(mmech.attributes["tons"].value) # Get BV. Should give prime variant BV for Omni-mechs # get first instance only to avoid problems with Omni-mechs self.batt_val = int(get_child_data(mmech, 'battle_value')) # Get Cost. cost = float(get_child_data(mmech, 'cost')) # Get production era self.prod_era = int(get_child_data(mmech, 'productionera')) # Get mech type (battle, industrial) self.mechtype = get_child_data(mmech, 'mech_type') # Only support battlemechs if (self.mechtype != "BattleMech" and self.mechtype != "PrimitiveBattleMech"): print self.name, self.model print "Industrial Mechs not supported!" sys.exit(1) # Get techbase (IS, Clan) # get first instance only to avoid problems with Omni-mechs self.techbase = get_child_data(mmech, 'techbase') # Get year self.year = int(get_child_data(mmech, 'year')) # Sanity check for year year_era_test(self.year, self.prod_era, self.name + " " + self.model) if (self.year < 2439): print self.name, self.model print "Battlemech older than Mackie!" sys.exit(1) if (self.year < 2470 and self.mechtype == "BattleMech"): print self.name, self.model print "Non-primitive BattleMechs not available before 2470!" sys.exit(1) if (self.year < 2854 and self.omni == "TRUE"): print self.name, self.model print "OmniMechs not available before 2854!" sys.exit(1) # Get motive type (biped, quad) self.motive = get_child_data(mmech, 'motive_type') ### Components starts here ### # Get internal structure type self.structure = MechStructure(get_child(mmech, 'structure'), self.weight, self.motive) # Get engine data self.engine = Engine(get_child(mmech, 'engine'), self) # Get gyro self.gyro = Gyro(get_child(mmech, 'gyro'), self.engine.etype, self.engine.erating) # Get cockpit self.cockpit = Cockpit(get_child(mmech, 'cockpit'), self) # Get enhancement, needs for loop self.enhancement = Enhancement(None, self.weight, self.engine.erating) for enh in mmech.getElementsByTagName('enhancement'): self.enhancement = Enhancement(enh, self.weight, self.engine.erating) # Get armor. self.armor = MechArmor(get_child(mmech, 'armor'), self.weight, self.motive) ### Loadout stuff starts here ### # Get baseloadout blo = mmech.getElementsByTagName('baseloadout')[0] # Get multi-slot stuff for mlts in blo.getElementsByTagName('multislot'): slot = mlts.attributes["name"].value self.multi.add(slot) # Construct current loadout, empty name for base loadout self.load = Baseloadout(blo, self, self.batt_val, self.prod_era, cost) # HACK -- Apply modular armor if self.load.gear.has_mod_armor: self.armor.apply_modular(self.load.gear.mod_armor) # Get omni loadouts self.loads = [] for load in mmech.getElementsByTagName('loadout'): # Construct current loadout current = Loadout(load, self.load, self) self.loads.append(current)
def __init__(self,player): Unit.__init__(self,player)
def __init__(self, uid, pos, images): Unit.__init__(self, pos, images, 200, 0, 25, uid, SUMA, SUBM, 10)
def __init__(self, health, mana, damage): self.damage = damage Unit.__init__(self, health, mana, damage)
def __init__(self): WEAPONS = [ShortSword(self)] Unit.__init__(self, "Skeleton", HP = 50, ATK = 10, DEF = 6, ACC = 7, EVA = 9, SPD = 5, weapons = WEAPONS) return
def __init__(self, name='Berserker', hit_points_limit=180): Unit.__init__(self, name, hit_points_limit) self.weapon = Axe(self)
def __init__(self): WEAPONS = [FireBall(self)] Unit.__init__(self, "Dragon", HP = 9999, ATK = 9999, DEF = 9999, MAG = 9999, RES = 9999, ACC = 9999, EVA = 9999, SPD = 9999, weapons = WEAPONS) return
def __init__(self, x, y, sprite, window, health, collisonradius, scale): Unit.__init__(self, x, y, sprite, window, health, collisonradius, scale)
def __init__(self, uid, pos, images): Unit.__init__(self, pos, images, 250, 0, 0, uid, SUBP, AUXI, 10)
def __init__(self, controlScheme, camera, game, xStart = 0, yStart = 0, zStart = 0): models = MODELS_PATH + "SleekCraft" anims = {} Unit.__init__(self, models, anims, "**/CollisionSphere", game, xStart, yStart, zStart) self.controlScheme = controlScheme self.camera = camera self.game = game #set up sounds self.thrustSound = game.loader.loadSfx(SFX_PATH + "thrust.wav") self.electricSound = game.loader.loadSfx(SFX_PATH + "electricity.wav") self.magnetSound = game.loader.loadSfx(SFX_PATH + "magnet.wav") #set up the collisions in unit #set up the headlamp specific to the model headLampMain = Spotlight('headLampMain') #headLampMain.showFrustum() headLampMain.setColor(VBase4(1.5, 1.5, 1.5, 1)) mlens = PerspectiveLens() mlens.setNearFar(0.25, 1500) headLampMain.setLens(mlens) headLampMainnode = self.attachNewNode(headLampMain) headLampMainnode.setPos(self.find("**/LightCubeMain").getPos()) headLampMainnode.setHpr(-180, 0, 0)#reverse completely because our model is backwards game.render.setLight(headLampMainnode) headLampLeft = Spotlight('headLampLeft') #headLampLeft.showFrustum() headLampLeft.setColor(VBase4(0.6, 0.6, 0.6, 1)) llens = PerspectiveLens() headLampLeft.setLens(llens) llens.setNearFar(0.25, 500) headLampLeftnode = self.attachNewNode(headLampLeft) headLampLeftnode.setPos(self.find("**/LightCubeLeft").getPos()) headLampLeftnode.setHpr(-105, 0, 0)#reverse completely because our model is backwards game.render.setLight(headLampLeftnode) headLampRight = Spotlight('headLampRight') #headLampRight.showFrustum() headLampRight.setColor(VBase4(0.6, 0.6, 0.6, 1)) rlens = PerspectiveLens() rlens.setNearFar(0.25, 500) headLampRight.setLens(rlens) headLampRightnode = self.attachNewNode(headLampRight) headLampRightnode.setPos(self.find("**/LightCubeRight").getPos()) headLampRightnode.setHpr(105, 0, 0)#reverse completely because our model is backwards game.render.setLight(headLampRightnode) self.maxHealth = 50 self.health = self.maxHealth self.collisionAttackPower = 0 #the currently active weapon self.currentWeapon = AREA #the maximum amount of energy available self.maxEnergy = 2000 #the amount of energy currently available self.energy = self.maxEnergy #the amount of energy that is restored each second self.energyRegen = 300 #the energy cost of attacking with a given weapon for one second self.magnetCost = {NARROW:self.energyRegen + 100, AREA:self.energyRegen + 120} #the strength of a sustained attack per unit of energy used self.magnetStrength = {NARROW:2.5, AREA:20} #the energy cost of a burst attack with a given weapon self.burstCost = {NARROW:0, AREA:600} #the strength of a burst attack with a given weapon #(yes, the area value really does have to be this high) self.burstStrength = {NARROW:90, AREA:7000} #the enemy that the narrow weapon has locked on to self.target = None #whether the player was attacking the previous frame; this is used #to determine whether to release a large burst or a smaller #sustained force self.sustainedAttack = False #action flag self.switchPressed = False self.extraForwardAccel = 2.2 self.accelMultiplier *= 1.2 self.maxTurnRate = 720 #self.shooting = False #used in main to check if the unit can be shot with the narrow attack self.shootable = False self.immune = False
def __init__(self, uid, pos, images): Unit.__init__(self, pos, images, 1000, 0, 500, uid, ALMI, SUBM, 10)
def __init__(self, name='Soldier', hit_points_limit=100): Unit.__init__(self, name, hit_points_limit) self.weapon = Sword(self)
def __init__(self, uid, pos, images): Unit.__init__(self, pos, images, 500, 15, 20, uid, CPFG, FRAG, 10)