def talking_sword(): c = Collection() sayings = ['Hiya!', 'Take this!', 'Have at you!'] sword = ItemType('talking_sword', cloneFrom='sword_iron', reactions=[ ItemReaction(element='actionTaken', action=callout_action(c, sayings)), ItemReaction(element='itemCombined', action=callout_action( c, ["Aaaaaah! I'm melting!"])) ]) c.append(sword) return c
def define_craftable_fences(): with collect_records() as c: original_wood_fence_types = [ 'fence_Mid', 'fence_NW', 'fence_N', 'fence_NE', 'fence_E', 'fence_SE', 'fence_SW', 'fence_W' ] wood_fences = [ ItemType( f'{fence_type}_crafted', cloneFrom=fence_type, description= 'Use an axe to chop it down or break it with a physical attack.', reactions=[ ItemReaction(element='heavySlash', newID='woodPlank'), ItemReaction( element='physical', aiRatingMod=100, aiRatingModForHostilesOnly=True, newID=ItemType( f'{fence_type}_crafted_weak', cloneFrom=fence_type, name='Fencepost (weak)', pB='zoneWoodDark', description= 'Looks like it will break with one more hit.', reactions=[ ItemReaction(element='physical', newID='X', aiRatingMod=100, aiRatingModForHostilesOnly=True) ])) ]) for fence_type in original_wood_fence_types ] kit = ItemType( 'craft_fence', cloneFrom='craft_sword', name='Fence Crafting Kit', texture='rcfox_farming_tools', sprite=13, description= 'Combine this with wood planks to create a fence, or with a fence to change the fence direction.' ) kit.recipe('woodPlank', wood_fences[0]) for fence1, fence2 in zip(wood_fences, wood_fences[1:] + wood_fences[:1]): kit.recipe(fence1.id, fence2.id)
def define_dummy(): with collect_records() as c: ActorPrefab('dehydrated_dummy', name='Dummy', skinPalette='pOrange', armorPalette='pOrange', unarmoredPalette='pOrange', clothPalette='pOrange', playerCanOpenInv=True, unkillable=True, hostile=False, faction='player', actorTypeID=ActorType( 'dehydrated_dummy', cloneFrom='dummy', reactions=[ ActorTypeReaction( element=['dispel', 'combatStart'], spawnItem='dehydrated_dummy_placeable', action=Action('dispel_dehydrated_dummy', av_affecters=[ AvAffecter( actorValue='removeActor', magnitude=1) ])), ])) item = ItemType( 'dehydrated_dummy_placeable', name='Dehydrated Dummy', description='Place it on the ground and add water.', sprite=26, pR='pOrange', itemCategory='tool', weight=1, volume=10, value=1000, reactions=[ ItemReaction(element='water', newID='X', action=Action( 'spawn_dummy', special='cantUseInCombat', av_affecters=[ AvAffecter(actorValue='summonActor', magnitude='dehydrated_dummy', chance=100, duration=Duration.permanent()), ])) ]) add_dialog(item) return c
def graph_to_plants(G): items = [] for node in G: if node == 'X': continue if 'properties' not in G.nodes[node]: continue reactions = [] for tail in G[node]: for i in G[node][tail]: edge = G[node][tail][i] element = edge['element'] spawnItem = edge.get('spawnItem', None) action = edge.get('action', None) r = ItemReaction(element=element, newID=tail, spawnItem=spawnItem, action=action) reactions.append(r) props = G.nodes[node].get('properties', {}) if 'reactions' in props: reactions.extend(props.pop('reactions')) ItemType(node, reactions=reactions, **props)
def define_corn(): G = networkx.MultiDiGraph() G.add_edge('corn', 'corn_seeds', element='smash', spawnItem=['corn_seeds', 'corn_seeds']) G.add_edge('corn_seeds', 'corn_seeds_watered', element='water') G.add_edge('corn_seeds_watered', 'corn_sprout', element='newDay', count=3, description='It will sprout in {days} day{s}.', element_targets={'dig': 'corn_seeds'}) destruction_elements = { 'fire': 'fire_small', 'slash': 'X' } G.add_edge('corn_sprout', 'corn_stalk', element='newDay', count=3, description='It will reach full length in {days} day{s}.', element_targets=destruction_elements) G.add_edge('corn_stalk', 'corn_stalk_flowering', element='newDay', count=8, description='It will flower in {days} day{s}.', element_targets=destruction_elements) G.add_edge('corn_stalk_flowering', 'corn_ripe', element='newDay', count=9, description='It will ripen in {days} day{s}.', element_targets=destruction_elements, action='reset_crop_harvest_ambush') G.add_edge('corn_seeds_watered', 'corn_seeds', element='dig') G.add_edge('corn_ripe', 'fire', element='fire') for item in ('corn_sprout', 'corn_stalk', 'corn_stalk_flowering'): for element, target in destruction_elements.items(): G.add_edge(item, target, element=element) journal = JournalEntry('journal_corn', category='item', halfPage=True, rarity=2, title='Corn', icons=['corn_sprout', 'corn_stalk', 'corn_stalk_flowering', 'corn_ripe', 'corn'], text='A tall, leafy plant that produces fruit as a cluster of sweet kernels. Fully grows after 23 days with only an minimal watering.') G.nodes['corn']['properties'] = dict( name='Cob of Corn', journalID=journal, itemCategory='plant', texture='rcfox_farming_crops', stackable=True, sprite=54, value=50, reactions=[MONSTER_EAT_CROP] ) G.nodes['corn_seeds']['properties'] = dict( name='Corn Seeds', journalID=journal, itemCategory='plant', texture='rcfox_farming_crops', sprite=59, description='With some water and time, will grow into corn.' ) G.nodes['corn_seeds_watered']['properties'] = dict( name='Corn Seeds (Watered)', journalID=journal, itemCategory='hide', cloneFrom='corn_seeds', special=['dontCloneReactions', 'cannotBePickedUp'] ) G.nodes['corn_sprout']['properties'] = dict( name='Corn Sprout', journalID=journal, itemCategory='plant', texture='rcfox_farming_crops', sprite=58, special=['cannotBePickedUp', 'adjustSpriteYUp8'], ) G.nodes['corn_stalk']['properties'] = dict( name='Corn Stalk', journalID=journal, itemCategory='plant', texture='rcfox_farming_crops', sprite=57, special=['cannotBePickedUp', 'adjustSpriteYUp8'], ) G.nodes['corn_stalk_flowering']['properties'] = dict( name='Corn Stalk (flowering)', journalID=journal, itemCategory='plant', texture='rcfox_farming_crops', sprite=56, special=['cannotBePickedUp', 'adjustSpriteYUp8'], ) G.nodes['corn_ripe']['properties'] = dict( name='Corn (ripe)', journalID=journal, itemCategory='plant', texture='rcfox_farming_crops', sprite=55, special=['cannotBePickedUp', 'adjustSpriteYUp8'], description='Ready to be harvested with a slashing tool.', reactions=[ MONSTER_EAT_CROP, ItemReaction(element=['slash'], newID='corn', action='activate_crop_harvest_ambush') ] ) graph_to_plants(expand_graph(G)) return 'corn_ripe', 'corn'
def define_wheat(): G = networkx.MultiDiGraph() G.add_edge('cargo_grain', 'wheat_seeds', element='smash', spawnItem=['wheat_seeds', 'wheat_seeds']) G.add_edge('wheat_seeds', 'wheat_seeds_watered', element='water') G.add_edge('wheat_seeds_watered', 'wheat_sprout', element='newDay', count=3, description='It will sprout in {days} day{s}.', element_targets={'dig': 'wheat_seeds'}) destruction_elements = { 'fire': 'fire_small', 'slash': 'X' } G.add_edge('wheat_sprout', 'wheat_grass', element='newDay', count=5, description='It will reach full length in {days} day{s}.', element_targets=destruction_elements) G.add_edge('wheat_grass', 'wheat_grass_flowering', element='newDay', count=6, description='It will flower in {days} day{s}.', element_targets=destruction_elements) G.add_edge('wheat_grass_flowering', 'wheat_ripe', element='newDay', count=7, description='It will ripen in {days} day{s}.', element_targets=destruction_elements, action='reset_crop_harvest_ambush') G.add_edge('wheat_seeds_watered', 'wheat_seeds', element='dig') G.add_edge('wheat_ripe', 'fire', element='fire') for item in ('wheat_sprout', 'wheat_grass', 'wheat_grass_flowering'): for element, target in destruction_elements.items(): G.add_edge(item, target, element=element) journal = JournalEntry('journal_wheat', category='item', halfPage=True, rarity=2, title='Wheat', icons=['wheat_sprout', 'wheat_grass', 'wheat_grass_flowering', 'wheat_ripe'], text='A grass cultivated for its seeds, which have a variety of uses. Fully grows after 21 days.') G.nodes['cargo_grain']['properties'] = dict( cloneFrom='cargo_grain', description='Hard, dry seed. Smash the crate open to get seeds you can plant.', reactions=[MONSTER_EAT_CROP] ) G.nodes['wheat_seeds']['properties'] = dict( name='Wheat Seeds', journalID=journal, itemCategory='plant', texture='rcfox_farming_crops', sprite=35, description='With some water and time, will grow into wheat.' ) G.nodes['wheat_seeds_watered']['properties'] = dict( name='Wheat Seeds (Watered)', journalID=journal, itemCategory='hide', cloneFrom='wheat_seeds', special=['dontCloneReactions', 'cannotBePickedUp'] ) G.nodes['wheat_sprout']['properties'] = dict( name='Wheat Sprout', journalID=journal, itemCategory='plant', texture='rcfox_farming_crops', sprite=34, special=['cannotBePickedUp', 'adjustSpriteYUp8'], ) G.nodes['wheat_grass']['properties'] = dict( name='Wheat Grass', journalID=journal, itemCategory='hide', texture='rcfox_farming_crops', sprite=33, special=['cannotBePickedUp', 'adjustSpriteYUp8'], ) G.nodes['wheat_grass_flowering']['properties'] = dict( name='Wheat Grass (flowering)', journalID=journal, itemCategory='plant', texture='rcfox_farming_crops', sprite=32, special=['cannotBePickedUp', 'adjustSpriteYUp8'], ) G.nodes['wheat_ripe']['properties'] = dict( name='Wheat (ripe)', journalID=journal, itemCategory='plant', texture='rcfox_farming_crops', sprite=31, special=['cannotBePickedUp', 'adjustSpriteYUp8'], description='Ready to be harvested with a slashing tool.', reactions=[ MONSTER_EAT_CROP, ItemReaction(element=['slash'], newID='cargo_grain', action='activate_crop_harvest_ambush') ] ) graph_to_plants(expand_graph(G)) return 'wheat_ripe', 'cargo_grain'
def define_turnip(): G = networkx.MultiDiGraph() G.add_edge('turnip', 'turnip_seeds', element='smash', spawnItem=['turnip_seeds', 'turnip_seeds']) G.add_edge('turnip_seeds', 'turnip_seeds_watered', element='water') G.add_edge('turnip_seeds_watered', 'turnip_sprout', element='newDay', count=3, description='It will sprout in {days} day{s}.', element_targets={'dig': 'turnip_seeds'}) G.add_edge('turnip_sprout', 'turnip_sprout_watered', element='water') G.add_edge('turnip_sprout_watered', 'turnip_mature', element='newDay', count=7, description='It will mature in {days} day{s}.', element_targets={'fire': 'fire_small', 'slash': 'X'}, action='reset_crop_harvest_ambush') G.add_edge('turnip_seeds_watered', 'turnip_seeds', element='dig') G.add_edge('turnip_sprout', 'X', element='slash') G.add_edge('turnip_sprout', 'fire_small', element='fire') G.add_edge('turnip_mature', 'fire_small', element='fire') journal = JournalEntry('journal_turnip', category='item', halfPage=True, rarity=2, title='Turnip', icons=['turnip_sprout', 'turnip_mature', 'turnip'], text='A versatile vegetable with both edible roots and leaves. Sprouts from a seed in 3 days and fully matures 7 days later, with occasional watering.') G.nodes['turnip']['properties'] = dict( name='Turnip', journalID=journal, itemCategory='plant', texture='rcfox_farming_crops', stackable=True, sprite=0, value=40, reactions=[MONSTER_EAT_CROP] ) G.nodes['turnip_seeds']['properties'] = dict( name='Turnip Seeds', journalID=journal, itemCategory='plant', texture='rcfox_farming_crops', sprite=5, description='With some water and time, will grow into a turnip.' ) G.nodes['turnip_seeds_watered']['properties'] = dict( name='Turnip Seeds (Watered)', journalID=journal, itemCategory='hide', cloneFrom='turnip_seeds', special=['dontCloneReactions', 'cannotBePickedUp'] ) G.nodes['turnip_sprout']['properties'] = dict( name='Turnip Sprout', journalID=journal, itemCategory='plant', texture='rcfox_farming_crops', sprite=2, special=['cannotBePickedUp', 'adjustSpriteYUp8'], description='Water it to continue its growth.', ) G.nodes['turnip_sprout_watered']['properties'] = dict( name='Turnip Sprout (watered)', journalID=journal, itemCategory='hide', cloneFrom='turnip_sprout', special=['dontCloneReactions', 'cannotBePickedUp', 'adjustSpriteYUp8'] ) G.nodes['turnip_mature']['properties'] = dict( name='Turnip (mature)', journalID=journal, itemCategory='plant', texture='rcfox_farming_crops', sprite=1, special=['cannotBePickedUp', 'adjustSpriteYUp8'], description='Ready to be pulled out of the ground!', reactions=[ MONSTER_EAT_CROP, ItemReaction(element=['use', 'dig'], newID='turnip', action='activate_crop_harvest_ambush') ] ) graph_to_plants(expand_graph(G)) return 'turnip_mature', 'turnip'
ActorTypeDetectAoE, AvAffecter, AvAffecterAOE, DialogNodeOverride, FormulaGlobal, GlobalTrigger, GlobalTriggerEffect, ItemReaction, ItemType, JournalEntry, collect_records, generate_id ) MONSTER_EAT_CROP = ItemReaction(element='fakeElec', newID='X', aiRatingMod=999, aiRatingModForHostilesOnly=True) def define_ambush(crops): Action('reset_crop_harvest_ambush', av_affecters=[ AvAffecter(actorValue='trigger', magnitude=GlobalTrigger('toggle_crop_harvest_ambush_on', [ GlobalTriggerEffect('setGlobalVar', strings=['crop_harvest_ambush'], floats=[0]) ])) ]) munch_crop = Action('munch_crop_attack',