def __init__(self): Arenas.SuperArena.__init__(self, "path/to/arena.gmf") # Don't forget to replace the above Arena.gmf path # Your early setup code goes here def Activate(self, on): # Your bot-related setup/shutdown code goes here return Arenas.SuperArena.Activate(self, on) def HazardsOn(self, on): # Your hazard setup code goes here return Arenas.SuperArena.HazardsOn(self, on) def Tick(self): # Your repeating code goes here return Arenas.SuperArena.Tick(self) def ZoneEvent(self, direction, id, robot, chassis): # Your event code goes here return True
def __init__(self): Arenas.SuperArena.__init__(self, "path/to/arena.gmf") # Don't forget to replace the above Arena.gmf path self.players = () def Activate(self, on): if on: self.players = plus.getPlayers() Arenas.SuperArena.Activate(self, on) def Tick(self): for player in self.players: if plus.getLocation(player)[1] < -5: plus.eliminatePlayer(player) return Arenas.SuperArena.Tick(self)
def HazardsOn(self, on): self.RegisterZone("pit_zone", 1) return Arenas.SuperArena.HazardsOn(self, on) def ZoneEvent(self, direction, id, robot, chassis): if id == 1 and chassis: plus.elimatePlayer(robot - 1) return True
def HazardsOn(self, on): if on: self.flame1 = Hazards.Flame((0, 0, 0), (0, 6, 0), (.2, .4, .2), .25) self.AddHazard(self.flame1) return Arenas.SuperArena.HazardsOn(self, on) def Tick(self): if self.bHazardsOn: self.flame1.Tick() return Arenas.SuperArena.Tick(self)
#plus.AddParticleEmitter(XYZ_StartingLocation, XYZ_EndingLocation, XYZ_Variance) - Creates a ParticleEmitter object that looks like fire. While emitting, the fire moves in the designated direction with some leeway if variance isn't set to (0,0,0) (each value in variance represents the amount of leeway the smoke will have in the X, Y, and Z directions)# .SetEmittting(Enabled) - Turns a ParticleEmitter object on/off (True/False). By default, the fire will not be emitting particles.#import Hazards#Hazards.Flame(XYZ_Location, XYZ_Velocity, XYZ_Variance, yOffset) - Create a Flame object that extends from Hazards.Hazard.# .Tick() - This should be called once per tick.# .ZoneEvent(Direction) - This should be called every time a bot enters a fire zone.# .FlameOff() - Turns off the Flame object's fire, damage, and sound effect. # .FlameOn() - Turns on the Flame object's fire, damage, and sound effect.
def HazardsOn(self, on): if on: self.RegisterZone("elec_zone", 1) self.electricity = Hazards.Electricity() self.AddHazard(self.electricity) return Arenas.SuperArena.HazardsOn(self, on) def Tick(self): if self.bHazardsOn: self.electricity.Tick() return Arenas.SuperArena.Tick(self) def ZoneEvent(self, direction, id, robot, chassis): if id == 1: self.electricity.ZoneEvent(direction, robot, chassis) return True
def HazardsOn(self, on): self.CreateLightning(0, (0, 40, 0), (0, 0, 0)) self.SetLightningVisible(0) return Arenas.SuperArena.HazardsOn(self, on)
#self.CreateLightning(LightningID, XYZ_StartingLocation, XYZ_EndingLocation) - Create lightning with the given ID and set the position of both ends.#self.SetLightningStartEnd(LightningID, XYZ_StartingLocation, XYZ_EndingLocation) - Change the position of both ends of the specified lightning id.#self.SetLightningVisible(LightningID, Showing) - Set the given lightning ID's visibility.#plus.zap(BotID, AmountOfSparks, Duration) - Surround the given bot's chassis with harmless sparks#import Hazards#Hazards.Electricity(XYZ_Location) - Creates an Electricity object that extends from Hazards.Hazard.# .Tick() - This should be called once per tick.# .Zap() - Call this if you want to zap any bot that is currently in a zone.# .Button() - Call this if you want to zap any bot that is currently in a zone.# .NumBotsInRange() - Returns the number of bots that would get shocked if you were to call the Zap method now.# .ZoneEvent(Direction, Robot, Chassis) - This should be called every time a bot enters a zone that should zap them.
#plus.emitSmoke(Intensity, XYZ_StartingLocation, XYZ_Direction, XYZ_Variance) - Creates smoke that moves in the designated direction with some leeway if variance isn't set to (0,0,0) (each value in variance represents the amount of leeway the smoke will have in the X, Y, and Z directions).#plus.force(BotID, X_Direction, Y_Direction, Z_Direction) - Applies a linear force onto the designated bot in the designated direction every time it is called.#plus.gravity(X_Direction, Y_Direction, Z_Direction) - Applies a linear force on all bots and objects in the arena in the designated direction every time the physics update.#plus.damage(BotID, ComponentID, Damage, XYZ_Coordinates) - Inflicts the specified amount of damage to the specified component on the given bot. The given coordinates are used for positioning the damage delivered.#plus.disable(BotID,True/False) - Turns the controls on or off for the designated bot (1 is off, 0 is on) (the designated bot may not be killed unless they are enabled first).#plus.addPoints(BotID, Points) - Increase the score of a selected bot by a selected number of points.#plus.eliminatePlayer(BotID) - Eliminates the designated bot ID.#plus.areHazardsOn() - Returns 1 if hazards are enabled (1 is the same as True and 0 is the same as False).#plus.isDefeated(BotID) - Returns 1 if the bot has been defeated (1 is the same as True and 0 is the same as False).#plus.isEliminated(BotID) - Returns 1 if the bot has been eliminated (1 is the same as True and 0 is the same as False).#plus.isMatchOver() - Returns 1 if match is over (1 is the same as True and 0 is the same as False).#plus.isMatchPaused() - Returns 1 if the Pause/Break button is activated (1 is the same as True and 0 is the same as False).#plus.rayTest(XYZ_StartingLocation, XYZ_EndingLocation) - If something is between the two points it will return the BotID (-1 if it is not a bot), the component ID (0 if chassis), the X_Coordinate of intersection, the Y_Coordinate of intersection, and the Z_Coordinate of intersection; otherwise it will return -1 for all five values if it doesn't hit anything. If it hits something that isn't a bot, the first two values are -1 while the rest are the XYZ of the point of intersection.
*GMID_HAVOK_RBCOLLECTION { *NODE_NAME RBCollection01 *NUM_DISABLED_PAIRS 0 *SOLVER_TYPE 0 *COUNT 1 *GMID_HAVOK_RIGIDBODY_LIST { *COUNT 1 *GMID_HAVOK_RIGIDBODY { *NODE_NAME spike *MASS 0 *ELASTICITY 0.300000 *FRICTION 0.500000 *OPTIMIZATION_LEVEL 0.500000 *UNYIELDING 0 *SIMULATION_GEOMETRY 3 *GEOMETRY_PROXY_NAME null *USE_DISPLAY_PROXY 0 *DISABLE_COLLISIONS 0 *INACTIVE 0 *DISPLAY_PROXY_NAME (null) *NODE_TM { *NODE_NAME spike *TM_ROW0 1.000000 0.000000 0.000000 *TM_ROW1 0.000000 1.000000 0.000000 *TM_ROW2 0.000000 0.000000 1.000000 *TM_ROW3 0.000000 0.000000 0.000000 } *HAVOK_GEO_TYPE Standard *NUMBER_OF_CHILDREN 0 } } }
def HazardsOn(self, on): if on: self.SetSubMaterialSound("spike", "metal", .8, "Sounds\\hzd_spike_hit.wav") return Arenas.SuperArena.HazardsOn(self, on)
#self.AddXtra(ObjectName, GMF, Alloy)#self.AddXtraSound(ObjectName, GMF, Alloy, SoundFile)#self.SetSubMaterial(ObjectName, Alloy, DamageValue)#self.SetSubMaterialSound(ObjectName, Alloy, DamageValue, SoundFile)
*GMID_HAVOK_RBCOLLECTION { *NODE_NAME RBCollection01 *NUM_DISABLED_PAIRS 0 *SOLVER_TYPE 0 *COUNT 1 *GMID_HAVOK_RIGIDBODY_LIST { *COUNT 1 *GMID_HAVOK_RIGIDBODY { *NODE_NAME crate *MASS 25 *ELASTICITY 0.300000 *FRICTION 0.500000 *OPTIMIZATION_LEVEL 0.500000 *UNYIELDING 0 *SIMULATION_GEOMETRY 3 *GEOMETRY_PROXY_NAME null *USE_DISPLAY_PROXY 0 *DISABLE_COLLISIONS 0 *INACTIVE 0 *DISPLAY_PROXY_NAME (null) *NODE_TM { *NODE_NAME crate *TM_ROW0 1.000000 0.000000 0.000000 *TM_ROW1 0.000000 1.000000 0.000000 *TM_ROW2 0.000000 0.000000 1.000000 *TM_ROW3 0.000000 0.000000 0.000000 } *HAVOK_GEO_TYPE Standard *NUMBER_OF_CHILDREN 0 } } }
def HazardsOn(self, on): if on: self.SetActive("crate", 1) return Arenas.SuperArena.HazardsOn(self, on)
def HazardsOn(self, on): if on: prism = self.AddPrismatic("base", "spike", -0.432429,0.791208,0.432429, 0, 1.1, 0) self.spike = Hazards.Spikes(prism, 40000, (5.85, 0, -5.87) self.AddHazard(spike) return Arenas.SuperArena.HazardsOn(self, on) def Tick(self): if self.bHazardsOn: self.spike.Tick() return Arenas.SuperArena.Tick(self) def ZoneEvent(self, direction, id, robot, chassis): if id == 0: self.spike.ZoneEvent(direction) return True
#self.AddPrismatic(ParentObjectName, ChildObjectName, X_Direction, Y_Direction, Z_Direction, MovementLimit1, MovementLimit2, 0) - Creates a PrismaticController object.# .ApplyForce(Amount) - Applies the given amount of linear force.# .Lock(Enabled) - Determines whether the actuating part is movable.# .SetAutoLock(Enabled) - Determines whether the prismatic automatically locks when it is at its longest and shortest length.# .SetDirection(Amount) - Sets the direction of movement and the amount of strength.# .SetPowerSettings(Amount1, Amount2) - Sets the amount of force and strength of the PrismaticController object.#import Hazards#Hazards.Spikes(Prismatic, Power, XYZ_Location) - Creates a Spikes object that extends from Hazards.Hazard.# .Tick() - This should be called once per tick.# .ZoneEvent(Direction) - This should be called every time a bot enters a zone that should zap them.# .FireTeeth() - You can call this if you just want to fire the actuator.#Hazards.Saws(Prismatic, XYZ_Location) - Creates a Saws object that extends from Hazards.Hazard.# .ZoneEvent(Direction) - This should be called every time a bot enters a zone that should zap them.# .MoveSaw(Amount) - Sets the direction of movement for the PrismaticController object and the amount of strength.#Hazards.PitSlider(Prismatic, Delay, XYZ_Location) - Creates a PitSlider object that extends from Hazards.Hazard.# .Tick() - This should be called once per tick.# .setactive(Enabled) - Starts/Stops the timer for moving the slider.
*GMID_HAVOK_CONSTRAINTSOLVER { *NODE_NAME CSolver01 *THRESHOLD 10 *RB_COLLECTION_NAME RBCollection01 *GMID_HAVOK_CONSTRAINT_LIST { *COUNT 1 *GMID_HAVOK_HINGE_CONSTRAINT { *NODE_NAME Hinge01 *NODE_TM { *NODE_NAME Hinge01 *TM_ROW0 1 0 0 *TM_ROW1 0 1 0 *TM_ROW2 0 0 1 *TM_ROW3 0 0 0 } *BODY1 base *BODY2 saw *POINT 0 0 0 *SPIN_AXIS 0 1 0 *IS_LIMITED 0 *FRICTION 0 *ANGLE_LIMITS -0.8 0 } } }
def HazardsOn(self, on): if on: self.hinge = self.GetHinge("Hinge01") self.hinge.SetAutoLocks(False, False) self.hinge.Lock(False) return Arenas.SuperArena.HazardsOn(self, on) def Tick(self): if self.bHazardsOn: self.hinge.SetPowerSettings(12, 150000) self.hinge.SetDirection(100) self.hinge.ApplyTorque(10) return Arenas.SuperArena.Tick(self)
#self.GetHinge(HingeName) - Creates a HingeController object.# .Lock(Enable) - Determines whether the hinge is locked or not.# .SetAutoLocks(Enable1, Enable2) - Determines whether the hinge locks when it reaches its limits.# .ApplyTorque(Amount) - Applies the given amount of rotational force.# .SetDirection(Amount) - Sets the direction of movement and the amount of strength.# .SetPowerSettings(Amount1, Amount2) - Sets the amount of force and strength of the PrismaticController object.# .SetLimits(Amount1, Amount2) - Programmatic alternative to setting the rotational limits inside of the GMF.#import Hazards#Hazards.HellRaiser(Hinge, XYZ_Location) - Creates a HellRaiser object that extends from Hazards.Hazard.# .Tick() - This should be called once per tick.# .RaiseHell() - Rotates the hinge in the positive direction with a sound effect and a high amount of force.# .LowerHell() - Rotates the hinge in the negative direction with a low amount of force.#Hazards.Hammer(Hinge, XYZ_Location) - Creates a Hammer object that extends from Hazards.Hazard.# .Tick() - This should be called once per tick.# .ZoneEvent(Direction) - This should be called every time a bot enters a hammer zone.# .Smash() - Rotates the hinge in the positive direction with a sound effect and a high amount of force.# .Retract() - Rotates the hinge in the negative direction with a low amount of force.# .Shutdown() - Sets all hinge values to zero.#Hazards.Smasher(Hinge1, Hinge2, XYZ_Location) - Creates a Smasher object that extends from Hazards.Hazard.# .Tick() - This should be called once per tick.# .ZoneEvent(Direction, Robot) - This should be called every time a bot enters a compactor zone.# .Smash() - Rotates both hinges in the positive direction with a high level of force.# .Retract() - Rotates both hings in the negative direction with a low level of force.# .Shutdown() - Sets all hinge values to zero.#Hazards.TrapDoor(Hinge, XYZ_Location) - Creates a TrapDoor object that extends from Hazards.Hazard.# .Trigger() - Activates the trap door.
FireThe fire particle effect can be accomplished in one line of code but, in order to have the sound effect and damage, you are going to need a lot more. That said, both Infogrames and the DSL team have already programmed a decent flamethrower inside of Hazards.py and DSLHaz.py that we can use. When I did a quick scan of the differences between the two, I found that DSL is using a slightly quieter sound effect with slightly more damage per tick. For my example, I'll use the one found in stock RA2.Code: (Fire Example) [Select] def HazardsOn(self, on): if on: self.flame1 = Hazards.Flame((0, 0, 0), (0, 6, 0), (.2, .4, .2), .25) self.AddHazard(self.flame1) return Arenas.SuperArena.HazardsOn(self, on) def Tick(self): if self.bHazardsOn: self.flame1.Tick() return Arenas.SuperArena.Tick(self)If you were to stick this in an arena, you would see a flamethrower shooting up from the middle of the arena and driving into it delivers damage. If you wanted to use the DSL version, you can just replace "Hazards.Flame" with "DSLHaz.Flame" and add "import DSLHaz" to the top section. You will also need "import Hazards" at the top of the file by all the other imports or it will crash.Just for reference, here are the commands specific to flames.Code: (Fire Commands) [Select]#plus.AddParticleEmitter(XYZ_StartingLocation, XYZ_EndingLocation, XYZ_Variance) - Creates a ParticleEmitter object that looks like fire. While emitting, the fire moves in the designated direction with some leeway if variance isn't set to (0,0,0) (each value in variance represents the amount of leeway the smoke will have in the X, Y, and Z directions)# .SetEmittting(Enabled) - Turns a ParticleEmitter object on/off (True/False). By default, the fire will not be emitting particles.#import Hazards#Hazards.Flame(XYZ_Location, XYZ_Velocity, XYZ_Variance, yOffset) - Create a Flame object that extends from Hazards.Hazard.# .Tick() - This should be called once per tick.# .ZoneEvent(Direction) - This should be called every time a bot enters a fire zone.# .FlameOff() - Turns off the Flame object's fire, damage, and sound effect. # .FlameOn() - Turns on the Flame object's fire, damage, and sound effect.A good example of this can be found in Bridge.py. If you are just looking for something cosmetic, the Epic Showdown Arena (bbhaz.py) has some really neat torches.