def set_device_item_action(item, triggered_effects): triggered_effects += [ action.TriggerAction("Use", 90, [DEVICE_ACTION_TAG, USER_ACTION_TAG]) ] item_trigger_effect = Composite(DEVICE_ACTION_TAG) item_trigger_effect.set_child( FlashItemEffect()) # todo: does this do anything? item_trigger_effect.set_child(AddEnergySpentEffect()) item_trigger_effect.set_child(RemoveAChargeEffect()) for triggered_effect in triggered_effects: item_trigger_effect.set_child(triggered_effect) item_trigger_effect.set_child(DataPoint("item", item)) item.set_child(item_trigger_effect)
def __init__(self): super(Wall, self).__init__() self.set_child(DataPoint(DataTypes.GAME_PIECE_TYPE, GamePieceTypes.TERRAIN)) self.set_child(Mover()) self.set_child(Position()) self.set_child(DungeonLevel()) self.set_child(CharPrinter()) self.set_child(GraphicCharTerrainCorners(colors.FLOOR_BG, colors.WALL_FG, icon.CAVE_WALLS_ROW2, [Wall, Door, Chasm])) self.set_child(Flag("is_solid")) self.set_child(Flag("is_opaque")) self.set_child(Flag("is_wall"))
def new_spider_web(): """ Spider web the player or other entities can get caught in. """ web = Composite() set_dungeon_feature_components(web) web.set_child( Description( "Spider Web", "A spider made this web, touch it and you might get stuck")) web.set_child(GraphicChar(None, colors.WHITE, icon.SPIDER + 2)) web.set_child(DataPoint(DataTypes.STRENGTH, 10)) web.set_child(StuckInSpiderWebShareTileEffect()) web.set_child(Flag(Flags.FLAMMABLE)) return web
def new_ammunition(game_state): """ A composite component representing a gun ammunition item. """ ammo = Composite() set_item_components(ammo, game_state) ammo.set_child(ItemType(ItemType.AMMO)) ammo.set_child(Flag("is_ammo")) ammo.set_child(Stacker("ammo", 10, random.randrange(2, 6))) ammo.set_child( Description("Gun Bullets", "These bullets will fit in most guns.")) ammo.set_child(GraphicChar(None, colors.GRAY, icon.AMMO2)) ammo.set_child(DataPoint(DataTypes.WEIGHT, 1)) ammo.set_child(PlayerAutoPickUp()) return ammo
def __init__(self): super(Door, self).__init__() self.set_child(DataPoint(DataTypes.GAME_PIECE_TYPE, GamePieceTypes.TERRAIN)) self.set_child(Mover()) self.set_child(Position()) self.set_child(DungeonLevel()) self.set_child(CharPrinter()) self.set_child(GraphicChar(colors.FLOOR_BG, colors.ORANGE_D, icon.DOOR)) self.set_child(Flag("is_solid")) self.set_child(Flag("is_opaque")) self.set_child(OpenDoorAction()) self.set_child(OpenDoorBumpAction()) self.set_child(Flag("is_door"))
def new_bomb(game_state): bomb = Composite() set_item_components(bomb, game_state) bomb.set_child(ItemType(ItemType.BOMB)) bomb.set_child(PlayerAutoPickUp()) bomb.set_child(GraphicChar(None, colors.GRAY_D, icon.BOMB)) bomb.set_child(DataPoint(DataTypes.WEIGHT, 4)) bomb.set_child( Description( "Bomb", "A ball filled gunpowder, with a fuse attached." "Throwing it will cause some serious damage.")) set_thrown_item_hit_floor_action(bomb, [ ExplodeTriggeredEffect(), LocalMessageEffect(messenger.ENTITY_EXPLODES) ]) return bomb
def new_boots_of_sneaking(game_state): """ A composite component representing a Boots Armor item. """ boots = Composite() set_item_components(boots, game_state) set_armor_components(boots) boots.set_child( Description("Boots of sneaking", "A smooth pair of boots, they make you more stealthy.")) boots.set_child(DataPoint(DataTypes.WEIGHT, 2)) boots.set_child(GraphicChar(None, colors.BLUE, icon.BOOTS)) boots.set_child(StatBonusEquipEffect("armor", 0)) boots.set_child(StatBonusEquipEffect(DataTypes.STEALTH, 3)) boots.set_child(EquipmentType(equipment.EquipmentTypes.BOOTS)) return boots
def new_leather_boots(game_state): """ A composite component representing a Boots Armor item. """ boots = Composite() set_item_components(boots, game_state) set_armor_components(boots) boots.set_child( Description( "Leather Boots", "A worn pair of boots, dry mud covers most of the leather.")) boots.set_child(DataPoint(DataTypes.WEIGHT, 4)) boots.set_child(GraphicChar(None, colors.ORANGE_D, icon.BOOTS)) boots.set_child(StatBonusEquipEffect("armor", 1)) boots.set_child(EquipmentType(equipment.EquipmentTypes.BOOTS)) return boots
def new_leather_cap(game_state): """ A composite component representing a Armor item. """ cap = Composite() set_item_components(cap, game_state) set_armor_components(cap) cap.set_child( Description( "Leather Cap", "An old cap made out of leather, this should keep some harm away.") ) cap.set_child(DataPoint(DataTypes.WEIGHT, 4)) cap.set_child(GraphicChar(None, colors.ORANGE_D, icon.HELM)) cap.set_child(StatBonusEquipEffect("armor", 1)) cap.set_child(EquipmentType(equipment.EquipmentTypes.HEADGEAR)) return cap
def new_leather_armor(game_state): """ A composite component representing a Armor item. """ armor = Composite() set_item_components(armor, game_state) set_armor_components(armor) armor.set_child( Description( "Leather Armor", "A worn leather armor. It's old, but should still protect you from some damage." )) armor.set_child(GraphicChar(None, colors.ORANGE_D, icon.ARMOR)) armor.set_child(StatBonusEquipEffect("armor", 2)) armor.set_child(EquipmentType(equipment.EquipmentTypes.ARMOR)) armor.set_child(DataPoint(DataTypes.WEIGHT, 10)) return armor
def new_boots_of_running(game_state): """ A composite component representing a Boots Armor item. """ boots = Composite() set_item_components(boots, game_state) set_armor_components(boots) boots.set_child( Description( "Boots of Running", "A light pair of boots, they make your movement speed faster.")) boots.set_child(DataPoint(DataTypes.WEIGHT, 2)) boots.set_child(GraphicChar(None, colors.GREEN, icon.BOOTS)) boots.set_child(StatBonusEquipEffect("armor", 0)) boots.set_child(EquipmentType(equipment.EquipmentTypes.BOOTS)) boots.set_child( StatBonusEquipEffect(DataTypes.MOVEMENT_SPEED, -gametime.quarter_turn)) return boots
def new_hammer(game_state): """ A composite component representing a Sword item. """ c = Composite() set_item_components(c, game_state) set_melee_weapon_component(c) c.set_child( Description("Hammer", "A heavy hammer, it may knock away enemies.")) c.set_child(GraphicChar(None, colors.GRAY, icon.HAMMER)) c.set_child(DataPoint(DataTypes.WEIGHT, 8)) c.set_child(damage_item_stat(1, 7)) c.set_child(accuracy_item_stat(8)) c.set_child(CritChanceBonusEffect(0.15)) c.set_child(crit_multiplier_item_stat(2)) c.set_child(KnockBackAttackEffect(0.35)) return c
def new_energy_sphere(game_state): """ A composite component representing a gun ammunition item. """ charge = Composite() set_item_components(charge, game_state) charge.set_child(ItemType(ItemType.ENERGY_SHPERE)) charge.set_child(Stacker("charge", 5, random.randrange(1, 3))) charge.set_child( Description("Energy Sphere", "These spheres are used to power ancient devices.")) charge.set_child( GraphicChar(None, colors.LIGHT_ORANGE, icon.BIG_CENTER_DOT)) charge.set_child(DataPoint(DataTypes.WEIGHT, 1)) charge.set_child(PlayerAutoPickUp()) set_use_item_action(CHARGE_ACTION_TAG, charge, [ action.TriggerAction("Charge Device", 90, [CHARGE_ACTION_TAG]), ChooseChargeDeviceTriggeredEffect() ]) return charge
def new_club(game_state): """ A composite component representing a Sword item. """ c = Composite() set_item_components(c, game_state) set_melee_weapon_component(c) c.set_child( Description("Club", "A thick wooden stick, It may be used as a weapon.")) c.set_child(GraphicChar(None, colors.ORANGE_D, icon.CLUB)) c.set_child(DataPoint(DataTypes.WEIGHT, 8)) c.set_child(damage_item_stat(1, 6)) c.set_child(accuracy_item_stat(8)) c.set_child(CritChanceBonusEffect(0.1)) c.set_child(crit_multiplier_item_stat(1.5)) c.set_child(StunAttackEffect(0.3)) return c
def new_giant_amoeba(game_state): amoeba = Composite() set_monster_components(amoeba, game_state) amoeba.set_child(StatusFlags([StatusFlags.IS_ALIVE])) amoeba.set_child(DataPoint(DataTypes.INTELLIGENCE, IntelligenceLevel.PLANT)) amoeba.set_child(EntityMessages("The amoeba seems to wobble with happiness.", "The amoeba melts away.")) amoeba.set_child(Description("Giant Amoeba", "A giant amoeba... How is this even possible?" "The amoeba seems to wobble in your direction...")) amoeba.set_child(GraphicChar(None, colors.LIGHT_GREEN, "0")) amoeba.set_child(Health(20)) amoeba.set_child(DataPoint(DataTypes.STRENGTH, 4)) amoeba.set_child(DataPoint(DataTypes.EVASION, 5)) amoeba.set_child(DataPoint(DataTypes.ACCURACY, 12)) amoeba.set_child(DataPoint(DataTypes.ARMOR, 4)) amoeba.set_child(DataPoint(DataTypes.MOVEMENT_SPEED, gametime.single_turn + gametime.one_third_turn)) amoeba.set_child(DataPoint(DataTypes.AWARENESS, 5)) amoeba.set_child(DataPoint(DataTypes.CLONE_FUNCTION, new_giant_amoeba)) amoeba.set_child(NaturalHealthRegain()) amoeba.set_child(SplitAtFullHealth()) return amoeba
def new_slime(game_state): slime = Composite() set_monster_components(slime, game_state) set_slime_components(slime) slime.set_child(SlimeCanShareTileEntityMover()) slime.set_child(DissolveEntitySlimeShareTileEffect()) slime.set_child(EntityMessages("The slime seems to wobble with happiness.", "The slime melts away.")) slime.set_child(Description("Slime", "Slime, slime, slime. Ugh, I hate Slimes." "The slime seem to sense at you...")) slime.set_child(GraphicChar(None, colors.GREEN, icon.SLIME)) slime.set_child(Health(35)) slime.set_child(DataPoint(DataTypes.STRENGTH, 2)) slime.set_child(DataPoint(DataTypes.EVASION, 6)) slime.set_child(DataPoint(DataTypes.ACCURACY, 12)) slime.set_child(DataPoint(DataTypes.ARMOR, 3)) slime.set_child(DataPoint(DataTypes.AWARENESS, 5)) slime.set_child(DataPoint(DataTypes.MINIMUM_DEPTH, 3)) slime.set_child(DataPoint(DataTypes.CLONE_FUNCTION, new_slime)) return slime
def new_claw(game_state): c = Composite() set_item_components(c, game_state) set_melee_weapon_component(c) c.set_child( Description("Claws", "A pair of gloves with sharp blades attached to them,")) c.set_child(GraphicChar(None, colors.CHAMPAGNE, icon.CLAWS)) c.set_child(DataPoint(DataTypes.WEIGHT, 5)) c.set_child(DamageType(DamageTypes.BLUNT)) c.set_child(damage_item_stat(1, 3)) c.set_child(accuracy_item_stat(17)) c.set_child(CritChanceBonusEffect(0.10)) c.set_child(crit_multiplier_item_stat(2)) c.set_child(ExtraSwingAttackEffect(0.15)) c.set_child(CounterAttackEffect(0.20)) c.set_child(BleedAttackEffect(0.30)) return c
def new_training_dummy(gamestate): monster = Composite() set_monster_components(monster, gamestate) monster.set_child(Description("Training Dummy", "A Man hybrid, it looks hostile.")) monster.set_child(EntityMessages("The monster looks at you.", "The monster falls dead.")) monster.set_child(GraphicChar(None, colors.CHAMPAGNE, icon.STATUE)) monster.set_child(Health(80)) monster.set_child(DataPoint(DataTypes.STRENGTH, 3)) monster.set_child(DataPoint(DataTypes.EVASION, 8)) monster.set_child(DataPoint(DataTypes.ACCURACY, 13)) monster.set_child(DataPoint(DataTypes.ARMOR, 100)) monster.set_child(DataPoint(DataTypes.AWARENESS, 5)) monster.set_child(DataPoint(DataTypes.MINIMUM_DEPTH, 99999)) monster.set_child(DoNothingActor()) return monster
def new_worm(gamestate): worm = Composite() set_monster_components(worm, gamestate) worm.set_child(Description("Worm", "It's a giant earth worm.")) worm.set_child(EntityMessages("The worm wiggles at you.", "The worm stops moving.")) worm.set_child(GraphicChar(None, colors.PINK, icon.BLOOD7 + 4)) worm.set_child(Health(4)) worm.set_child(DataPoint(DataTypes.STRENGTH, 3)) worm.set_child(DataPoint(DataTypes.EVASION, 6)) worm.set_child(DataPoint(DataTypes.ACCURACY, 5)) worm.set_child(DataPoint(DataTypes.ARMOR, 2)) worm.set_child(DataPoint(DataTypes.AWARENESS, 3)) worm.set_child(DataPoint(DataTypes.MOVEMENT_SPEED, gametime.one_and_half_turn)) return worm
def new_ghost(gamestate): ghost = Composite() set_monster_components(ghost, gamestate) set_ghost_components(ghost) ghost.set_child(EntityMessages("The ghost sees you.", "The ghost fades away.")) ghost.set_child(Description("Ghost", "A spirit of a hunted creature.")) ghost.set_child(GraphicChar(None, colors.LIGHT_BLUE, icon.GHOST)) ghost.set_child(Health(1)) ghost.set_child(DataPoint(DataTypes.STRENGTH, 2)) ghost.set_child(DataPoint(DataTypes.EVASION, 14)) ghost.set_child(DataPoint(DataTypes.ACCURACY, 9)) ghost.set_child(DataPoint(DataTypes.ARMOR, 0)) ghost.set_child(DataPoint(DataTypes.MOVEMENT_SPEED, gametime.single_turn + gametime.one_third_turn)) ghost.set_child(DataPoint(DataTypes.AWARENESS, 8)) ghost.set_child(KeepPlayerAtDistanceActor(4)) ghost.set_child(SpiritMissile(150)) ghost.set_child(AddGhostReviveToSeenEntities()) ghost.set_child(DataPoint(DataTypes.MINIMUM_DEPTH, 2)) return ghost
def new_floating_eye(game_state): c = Composite() set_monster_components(c, game_state) c.set_child(StatusFlags([StatusFlags.IS_ALIVE, StatusFlags.FLYING])) c.set_child(DataPoint(DataTypes.INTELLIGENCE, IntelligenceLevel.PLANT)) c.set_child(EntityMessages("The eye looks intently.", "The eye falls to the ground.")) c.set_child(Description("Floating Eye", "A giant eye floating in mid-air How is this even possible?" "The eye stairs at you...")) c.set_child(GraphicChar(None, colors.WHITE, icon.EYE)) c.set_child(Health(20)) c.set_child(DataPoint(DataTypes.STRENGTH, 4)) c.set_child(DataPoint(DataTypes.EVASION, 8)) c.set_child(DataPoint(DataTypes.ACCURACY, 12)) c.set_child(DataPoint(DataTypes.ARMOR, 0)) c.set_child(DataPoint(DataTypes.MOVEMENT_SPEED, gametime.one_and_half_turn)) c.set_child(DataPoint(DataTypes.AWARENESS, 10)) c.set_child(ParalyzeOnStare(0, c.sight_radius.value, 100)) c.set_child(KeepPlayerAtDistanceActor(3)) return c
def new_whip(game_state): """ A composite component representing a Sword item. """ c = Composite() set_item_components(c, game_state) set_melee_weapon_component(c) c.set_child( Description("Whip", "An unusual weapon, most often used for torture.")) c.set_child(GraphicChar(None, colors.ORANGE_D, icon.WHIP)) c.set_child(DataPoint(DataTypes.WEIGHT, 8)) c.set_child(accuracy_item_stat(10)) c.set_child(damage_item_stat(1, 4)) c.set_child(CritChanceBonusEffect(0.15)) c.set_child(crit_multiplier_item_stat(2.5)) c.set_child(TripAttackEffect(0.50)) c.set_child(DefenciveAttackEffect(0.30)) c.set_child(StunAttackEffect(0.10)) return c
def new_scimitar(game_state): """ A composite component representing a Sword item. """ sword = Composite() set_item_components(sword, game_state) set_melee_weapon_component(sword) sword.set_child( Description("Scimitar", "A curved sword, an ancient design from the east.")) sword.set_child(GraphicChar(None, colors.WHITE, icon.SCIMITAR)) sword.set_child(DataPoint(DataTypes.WEIGHT, 8)) sword.set_child(damage_item_stat(2, 5)) sword.set_child(accuracy_item_stat(12)) sword.set_child(CritChanceBonusEffect(0.2)) sword.set_child(crit_multiplier_item_stat(2.5)) sword.set_child(ExtraSwingAttackEffect(0.1)) sword.set_child(DefenciveAttackEffect(0.1)) sword.set_child(OffenciveAttackEffect(0.1)) return sword
def new_rapier(game_state): """ A composite component representing a Sword item. """ sword = Composite() set_item_components(sword, game_state) set_melee_weapon_component(sword) sword.set_child( Description("Rapier", "A sword with a thin sharp blade, swift but deadly.")) sword.set_child(GraphicChar(None, colors.CHAMPAGNE, icon.RAPIER)) sword.set_child(DataPoint(DataTypes.WEIGHT, 8)) sword.set_child(damage_item_stat(2, 5)) sword.set_child(accuracy_item_stat(10)) sword.set_child(CritChanceBonusEffect(0.2)) sword.set_child(crit_multiplier_item_stat(2.5)) sword.set_child(ExtraSwingAttackEffect(0.1)) sword.set_child(CounterAttackEffect(0.1)) sword.set_child(OffenciveAttackEffect(0.1)) return sword
def new_cestus(game_state): c = Composite() set_item_components(c, game_state) set_melee_weapon_component(c) c.set_child( Description( "Cestus", "A pair of leather battle gloves, they improve your punches.")) c.set_child(GraphicChar(None, colors.ORANGE_D, icon.GLOVE)) c.set_child(DataPoint(DataTypes.WEIGHT, 5)) c.set_child(DamageType(DamageTypes.BLUNT)) c.set_child(damage_item_stat(1, 3)) c.set_child(accuracy_item_stat(17)) c.set_child(CritChanceBonusEffect(0.10)) c.set_child(crit_multiplier_item_stat(2)) c.set_child(ExtraSwingAttackEffect(0.3)) c.set_child(CounterAttackEffect(0.2)) c.set_child(StunAttackEffect(0.2)) return c
def new_katar(game_state): """ A composite component representing a Knife item. """ c = Composite() set_item_components(c, game_state) set_melee_weapon_component(c) c.set_child( Description("Katar", "A blade with an unusual handle, it looks ancient.")) c.set_child(GraphicChar(None, colors.CHAMPAGNE, icon.KATAR)) c.set_child(DataPoint(DataTypes.WEIGHT, 5)) c.set_child(DamageType(DamageTypes.CUTTING)) c.set_child(damage_item_stat(1, 3)) c.set_child(accuracy_item_stat(17)) c.set_child(CritChanceBonusEffect(0.10)) c.set_child(crit_multiplier_item_stat(3)) c.set_child(ExtraSwingAttackEffect(0.2)) c.set_child(CounterAttackEffect(0.2)) return c
def new_axe(game_state): """ A composite component representing a Sword item. """ c = Composite() set_item_components(c, game_state) set_melee_weapon_component(c) c.set_child( Description( "Axe", "This old axe has seen many battles, but age hasn't dulled the blade." )) c.set_child(GraphicChar(None, colors.GRAY, icon.AXE)) c.set_child(DataPoint(DataTypes.WEIGHT, 10)) c.set_child(damage_item_stat(3, 5)) c.set_child(accuracy_item_stat(8)) c.set_child(CritChanceBonusEffect(0.1)) c.set_child(crit_multiplier_item_stat(2)) c.set_child(OffenciveAttackEffect(0.75)) c.set_child(BleedAttackEffect(0.1)) return c
def new_halberd(game_state): """ A composite component representing a Sword item. """ c = Composite() set_item_components(c, game_state) set_melee_weapon_component(c) c.set_child( Description( "Halberd", "A long stick with a with an axe-head at one end." "It's a useful weapon when you want to keep danger at bay.")) c.set_child(GraphicChar(None, colors.GRAY, icon.HALBERD)) c.set_child(DataPoint(DataTypes.WEIGHT, 8)) c.set_child(accuracy_item_stat(10)) c.set_child(damage_item_stat(1, 5)) c.set_child(CritChanceBonusEffect(0.1)) c.set_child(crit_multiplier_item_stat(2)) c.set_child(DefenciveAttackEffect(0.75)) c.set_child(OffenciveAttackEffect(0.20)) return c
def new_spear(game_state): """ A composite component representing a Sword item. """ c = Composite() set_item_components(c, game_state) set_melee_weapon_component(c) c.set_child( Description( "Spear", "A stick with a sharp piece of metal at one end." "It's a useful weapon when you want to keep danger at bay.")) c.set_child(GraphicChar(None, colors.GRAY, icon.SPEAR)) c.set_child(DataPoint(DataTypes.WEIGHT, 8)) c.set_child(accuracy_item_stat(10)) c.set_child(damage_item_stat(1, 5)) c.set_child(CritChanceBonusEffect(0.1)) c.set_child(crit_multiplier_item_stat(2)) c.set_child(DefenciveAttackEffect(0.75)) c.set_child(CounterAttackEffect(0.1)) return c
def new_flail(game_state): """ A composite component representing a Sword item. """ c = Composite() set_item_components(c, game_state) set_melee_weapon_component(c) c.set_child( Description( "Flail", "A wooden handle with a chain and metal ball attached to it.")) c.set_child(GraphicChar(None, colors.GRAY, icon.FLAIL)) c.set_child(DataPoint(DataTypes.WEIGHT, 8)) c.set_child(damage_item_stat(1, 7)) c.set_child(accuracy_item_stat(7)) c.set_child(CritChanceBonusEffect(0.15)) c.set_child(crit_multiplier_item_stat(2)) c.set_child(IgnoreArmorAttackEffect(0.3)) c.set_child(KnockBackAttackEffect(0.2)) c.set_child(OffenciveAttackEffect(0.1)) return c