def new_steam_cloud(game_state, density): cloud = Composite() set_cloud_components(game_state, cloud, density) cloud.graphic_char.color_fg = colors.WHITE cloud.set_child(CloudActor()) cloud.set_child(DataPoint(DataTypes.CLONE_FUNCTION, new_steam_cloud)) cloud.set_child(DataPoint(DataTypes.CLOUD_TYPE, CloudTypes.STEAM)) return cloud
def new_frost_cloud(game_state, density): cloud = Composite() set_cloud_components(game_state, cloud, density) cloud.graphic_char.color_fg = colors.LIGHT_BLUE cloud.set_child(CloudActor()) cloud.set_child(DataPoint(DataTypes.CLONE_FUNCTION, new_frost_cloud)) cloud.set_child(DataPoint(DataTypes.CLOUD_TYPE, CloudTypes.FROST)) cloud.set_child(FrostCloudShareTileEffect()) return cloud
def new_poison_cloud(game_state, density): cloud = Composite() set_cloud_components(game_state, cloud, density) cloud.graphic_char.color_fg = colors.GREEN cloud.set_child(CloudActor()) cloud.set_child(DataPoint(DataTypes.CLONE_FUNCTION, new_poison_cloud)) cloud.set_child(DataPoint(DataTypes.CLOUD_TYPE, CloudTypes.POISON)) cloud.set_child(PoisonCloudShareTileEffect()) return cloud
def new_dust_cloud(game_state, density): cloud = Composite() set_cloud_components(game_state, cloud, density) cloud.graphic_char.color_fg = colors.LIGHT_ORANGE cloud.set_child(CloudActor()) cloud.set_child(DataPoint(DataTypes.CLONE_FUNCTION, new_dust_cloud)) cloud.set_child(DustLowerHitOfEntityShareTileEffect()) cloud.set_child(DataPoint(DataTypes.CLOUD_TYPE, CloudTypes.DUST)) return cloud
def get_dummy_actor(): dummy_actor = Composite() dummy_actor.set_child(DoNothingActor()) dummy_actor.set_child(Equipment()) dummy_actor.set_child(DataPoint(DataTypes.ENERGY, -gametime.single_turn)) dummy_actor.set_child(DataPoint(DataTypes.OFFENCIVE_ATTACK_CHANCE, 0.0)) dummy_actor.set_child(DataPoint(DataTypes.COUNTER_ATTACK_CHANCE, 0.0)) dummy_actor.set_child(DataPoint(DataTypes.DEFENCIVE_ATTACK_CHANCE, 0.0)) dummy_actor.set_child(DataPoint(DataTypes.CRIT_CHANCE, 0.0)) return dummy_actor
def new_explosion_cloud(game_state, density): explosion = Composite() set_cloud_components(game_state, explosion, density) explosion.graphic_char.color_fg = colors.YELLOW explosion.set_child(Description("Explosion", "Don't go near it.")) explosion.set_child(DisappearCloudActor()) explosion.set_child(ExplosionDamageShareTileEffect()) explosion.set_child( DataPoint(DataTypes.CLONE_FUNCTION, new_explosion_cloud)) explosion.set_child(DataPoint(DataTypes.CLOUD_TYPE, CloudTypes.EXPLOSION)) return explosion
def new_fire_cloud(game_state, density): fire = Composite() set_cloud_components(game_state, fire, density) set_non_flying_cloud_components(fire) fire.graphic_char.icon = icon.FIRE fire.graphic_char.color_fg = colors.RED fire.set_child(Description("Fire", "Don't get burnt.")) fire.set_child(SpreadToFlammableDisappearActor()) fire.set_child(FireDamageShareTileEffect()) fire.set_child(DataPoint(DataTypes.CLONE_FUNCTION, new_fire_cloud)) fire.set_child(DataPoint(DataTypes.CLOUD_TYPE, CloudTypes.FIRE)) return fire
def set_cloud_components(game_state, cloud, density): cloud.set_child(DataPoint(DataTypes.ENERGY, -gametime.single_turn)) cloud.set_child(DataPoint(DataTypes.GAME_PIECE_TYPE, GamePieceTypes.CLOUD)) cloud.set_child(DataPoint(DataTypes.GAME_STATE, game_state)) cloud.set_child(CharPrinter()) cloud.set_child(Position()) cloud.set_child(DungeonLevel()) cloud.set_child(Mover()) cloud.set_child(GraphicChar(None, None, 178)) cloud.set_child(DataPoint(DataTypes.DENSITY, density)) cloud.set_child(DataPoint(DataTypes.MOVEMENT_SPEED, gametime.single_turn)) cloud.set_child(StatusFlags([StatusFlags.FLYING])) cloud.set_child(CloudChangeAppearanceShareTileEffect())
def set_corpse_components(corpse, game_state): corpse.set_child(DataPoint(DataTypes.GAME_PIECE_TYPE, GamePieceTypes.DUNGEON_TRASH)) corpse.set_child(Position()) corpse.set_child(DungeonLevel()) corpse.set_child(Description("A rotting corpse.", "A rotting corpse.")) corpse.set_child(GraphicChar(None, colors.WHITE, icon.CORPSE)) corpse.set_child(CharPrinter()) corpse.set_child(DataPoint(DataTypes.ENERGY, -gametime.single_turn)) corpse.set_child(DoNothingActor()) corpse.set_child(Mover()) corpse.set_child(DataPoint(DataTypes.GAME_STATE, game_state))
def new_drop_action(component_type, item): effect = Composite(component_type) effect.set_child(DropItemTriggeredEffect()) effect.set_child(DataPoint("item", item)) effect.set_child( action.TriggerAction("Drop", 110, [DROP_ACTION_TAG, USER_ACTION_TAG])) item.set_child(effect)
def effect(self, **kwargs): target_entity = kwargs["target_entity"] source_entity = kwargs["source_entity"] if target_entity.has("effect_queue"): sight_radius_spoof = DataPoint(DataTypes.SIGHT_RADIUS, 1) darkness_effect = AddSpoofChild(source_entity, sight_radius_spoof, time_to_live=1) target_entity.effect_queue.add(darkness_effect)
def new_chain_and_ball(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( "Chain and Spike Ball", "A huge metal ball on a chain, hard to use but can deal massive damage." )) c.set_child(GraphicChar(None, colors.GRAY, icon.BALL_AND_CHAIN)) c.set_child(DataPoint(DataTypes.WEIGHT, 8)) c.set_child(damage_item_stat(2, 9)) c.set_child(accuracy_item_stat(5)) c.set_child(CritChanceBonusEffect(0.10)) c.set_child(crit_multiplier_item_stat(2)) c.set_child(KnockBackAttackEffect(0.20)) c.set_child(DefenciveAttackEffect(0.60)) c.set_child(IgnoreArmorAttackEffect(0.10)) return c
def new_trident(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( "Trident", "A long stick with a with three sharp points at one end." "It's a useful weapon when you want to keep danger at bay.")) c.set_child(GraphicChar(None, colors.ORANGE_D, icon.TRIDENT)) 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.15)) c.set_child(crit_multiplier_item_stat(2.5)) c.set_child(DefenciveAttackEffect(0.75)) c.set_child(BleedAttackEffect(0.20)) return c
def new_dagger(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( "Dagger", "A trusty dagger, small and precise but will only inflict small wounds." )) c.set_child(GraphicChar(None, colors.GRAY, icon.DAGGER)) 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(15)) c.set_child(CritChanceBonusEffect(0.2)) c.set_child(crit_multiplier_item_stat(3.5)) c.set_child(ExtraSwingAttackEffect(0.20)) c.set_child(BleedAttackEffect(0.10)) return c
def new_morning_star(game_state): """ A composite component representing a Sword item. """ mace = Composite() set_item_components(mace, game_state) set_melee_weapon_component(mace) mace.set_child( Description( "Morning Star", "This old club has an lump of iron with rusty spikes at one end.")) mace.set_child(GraphicChar(None, colors.GRAY, icon.MORNING_STAR)) mace.set_child(DataPoint(DataTypes.WEIGHT, 8)) mace.set_child(accuracy_item_stat(8)) mace.set_child(damage_item_stat(1, 6)) mace.set_child(CritChanceBonusEffect(0.1)) mace.set_child(crit_multiplier_item_stat(2)) mace.set_child(StunAttackEffect(0.2)) mace.set_child(IgnoreArmorAttackEffect(0.2)) mace.set_child(BleedAttackEffect(0.1)) return mace
def new_kris(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( "Kris", "A dagger with a wavy blade, its sharp end can cause major damage." )) c.set_child(GraphicChar(None, colors.GRAY_D, icon.KRIS)) 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(15)) c.set_child(CritChanceBonusEffect(0.20)) c.set_child(crit_multiplier_item_stat(3.5)) c.set_child(ExtraSwingAttackEffect(0.2)) c.set_child(BleedAttackEffect(0.2)) return c
def new_throw_item_action(component_type, item): effect = Composite(component_type) effect.set_child(DropItemTriggeredEffect()) effect.set_child(DataPoint("item", item)) effect.set_child( action.TriggerAction("Throw", 110, [THROW_ACTION_TAG, USER_ACTION_TAG])) item.set_child(effect)
def __init__(self): super(PoolOfBlood, self).__init__() self.set_child(DataPoint(DataTypes.GAME_PIECE_TYPE, GamePieceTypes.DUNGEON_TRASH)) self.set_child(Position()) self.set_child(DungeonLevel()) self.set_child(Description("A pool of blood.", "A pool of blood.")) self.set_child(GraphicChar(None, colors.RED, random.choice(icon.BLOOD_ICONS))) self.set_child(CharPrinter()) self.set_child(Mover())
def new_flame_orb(game_state): orb = Composite() set_item_components(orb, game_state) set_ranged_weapon_components(orb) orb.set_child(RangeWeaponType(RangeWeaponType.MAGIC)) orb.set_child( Description( "Flame Orb", "An orb with a living flame inside, it allows the wielder to channel fire from it." )) orb.set_child(GraphicChar(None, colors.RED, icon.ORB)) orb.set_child(DataPoint(DataTypes.WEAPON_RANGE, 5)) orb.set_child(DataPoint(DataTypes.WEIGHT, 2)) orb.set_child(accuracy_item_stat(5)) orb.set_child(Damage(2, 4)) orb.set_child( MagicMissileEffect(GraphicChar(None, colors.RED, icon.BIG_CENTER_DOT))) return orb
def set_use_item_action(component_type, item, triggered_effects): item_trigger_effect = Composite(component_type) item_trigger_effect.set_child( FlashItemEffect()) # todo: does this do anything? item_trigger_effect.set_child(AddEnergySpentEffect()) 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 set_scroll_components(item): item.set_child(ItemType(ItemType.SCROLL)) item.set_child(PlayerAutoPickUp()) item.set_child(DataPoint(DataTypes.WEIGHT, 1)) item.set_child(GraphicChar(None, colors.CHAMPAGNE, icon.SCROLL)) set_thrown_item_hit_floor_action(item, [ MoveTriggeredEffect(), LocalMessageEffect(messenger.ITEM_HITS_THE_GROUND_LIGHT) ])
def __init__(self): super(GlassWall, 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(GraphicChar(colors.FLOOR_BG, colors.WHITE, icon.GLASS_WALL)) self.set_child(CharPrinter()) self.set_child(Flag("is_solid"))
def set_dungeon_feature_components(dungeon_feature): dungeon_feature.set_child( DataPoint(DataTypes.GAME_PIECE_TYPE, GamePieceTypes.DUNGEON_FEATURE)) dungeon_feature.set_child(Position()) dungeon_feature.set_child(DungeonLevel()) dungeon_feature.set_child(GraphicChar(None, colors.RED, icon.FOUNTAIN_FULL)) dungeon_feature.set_child(CharPrinter()) dungeon_feature.set_child(Mover()) dungeon_feature.set_child(IsDungeonFeature())
def __init__(self): super(Water, 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(GraphicChar(colors.BLUE_D, colors.BLUE, icon.WATER)) self.set_child(CharPrinter())
def trigger(self, **kwargs): ttl = gametime.single_turn * rng.random_variance(10, 5) source_entity = kwargs[action.SOURCE_ENTITY] entities = source_entity.dungeon_level.value.entities for entity in entities: sight_radius_spoof = DataPoint(DataTypes.SIGHT_RADIUS, 1) darkness_effect = entityeffect.AddSpoofChild(source_entity, sight_radius_spoof, time_to_live=ttl) entity.effect_queue.add(darkness_effect)
def __init__(self): super(Floor, 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(GraphicChar(colors.FLOOR_BG, colors.FLOOR_FG, icon.CENTER_DOT)) self.set_child(CharPrinter()) self.set_child(Flag(Floor.FLOOR_FLAG))
def set_up_new_entity_with_dungeon(self, dungeon_level): entity = Composite() entity.set_child(Mover()) entity.set_child(Position()) entity.set_child(DataPoint(DataTypes.GAME_PIECE_TYPE, GamePieceTypes.ENTITY)) dungeon_level_component = DungeonLevel() dungeon_level_component.value = dungeon_level entity.set_child(dungeon_level_component) return entity
def set_item_components(item, game_state): item.set_child(DataPoint(DataTypes.ENERGY, -gametime.single_turn)) item.set_child(Position()) item.set_child(DoNothingActor()) item.set_child(DungeonLevel()) item.set_child(Mover()) item.set_child(DataPoint(DataTypes.GAME_PIECE_TYPE, GamePieceTypes.ITEM)) item.set_child(DataPoint(DataTypes.GAME_STATE, game_state)) item.set_child(CharPrinter()) new_drop_action(DROP_ACTION_TAG, item) item.set_child(PlayerThrowItemAction()) set_thrown_item_hit_floor_action(item, [ MoveTriggeredEffect(), LocalMessageEffect(messenger.ITEM_HITS_THE_GROUND_HEAVY) ]) set_thrown_item_hit_chasm_action(item, [ MoveTriggeredEffect(), LocalMessageEffect(messenger.ITEM_FALLS_DOWN_CHASM) ]) return item
def _copy_add_children_helper(self, old_piece): new_piece = compositecore.Composite() if old_piece.has("game_piece_type"): new_piece.set_child( DataPoint(DataTypes.GAME_PIECE_TYPE, old_piece.game_piece_type.value)) if old_piece.has("graphic_char"): new_piece.set_child(old_piece.graphic_char.copy()) if old_piece.has("description"): new_piece.set_child(old_piece.description.copy()) new_piece.set_child(CharPrinter()) return new_piece
def new_bolas(game_state): sling = Composite() set_item_components(sling, game_state) set_ranged_weapon_components(sling) sling.set_child(RangeWeaponType(RangeWeaponType.SLING)) sling.set_child( Description( "Bolas", "Two weights strung together by a string, when thrown they may trip the victim." )) sling.set_child(GraphicChar(None, colors.CHAMPAGNE, icon.HEART + 18)) sling.set_child(DataPoint(DataTypes.WEAPON_RANGE, 4)) sling.set_child(DataPoint(DataTypes.WEIGHT, 3)) sling.set_child(accuracy_item_stat(3)) sling.set_child(damage_item_stat(1, 2)) sling.set_child(CritChanceBonusEffect(0.2)) sling.set_child(crit_multiplier_item_stat(2.0)) sling.set_child(TripAttackEffect(0.4)) return sling