[wpdev-commits] xmlscripts/scripts beverage.py,1.2,1.3
Brought to you by:
rip,
thiagocorrea
From: Sebastian H. <dar...@us...> - 2004-07-24 19:02:09
|
Update of /cvsroot/wpdev/xmlscripts/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8803 Modified Files: beverage.py Log Message: More options for the beverage script Index: beverage.py =================================================================== RCS file: /cvsroot/wpdev/xmlscripts/scripts/beverage.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** beverage.py 23 Jul 2004 19:40:00 -0000 1.2 --- beverage.py 24 Jul 2004 19:02:01 -0000 1.3 *************** *** 4,78 **** import random ! # Baseid: ClilocBaseId, MaxQuantity, Empty Item Id CONTAINERS = { ! 0x9c8: [1042965, 10, 0], # Jug ! 0x99f: [1042959, 5, 0], # Bottle of Ale ! 0x99b: [1042959, 5, 0], # Bottle of Liquor ! 0x9c7: [1042959, 5, 0], # Bottle of Wine # Ceramic Mugs ! 0x995: [1042982, 1, 0x995], ! 0x996: [1042982, 1, 0x995], ! 0x997: [1042982, 1, 0x995], ! 0x998: [1042982, 1, 0x995], ! 0x999: [1042982, 1, 0x995], ! 0x9CA: [1042982, 1, 0x995], # Pewter Mugs ! 0xFFF: [1042994, 1, 0xFFF], ! 0x1000: [1042994, 1, 0xFFF], ! 0x1001: [1042994, 1, 0xFFF], ! 0x1002: [1042994, 1, 0xFFF], # Goblet ! 0x99A: [1043000, 1, 0x99A], ! 0x9B3: [1043000, 1, 0x99A], ! 0x9BF: [1043000, 1, 0x99A], ! 0x9CB: [1043000, 1, 0x99A], # Glass Mug ! 0x1F7D: [1042976, 5, 0x1F81], ! 0x1F7E: [1042976, 5, 0x1F81], ! 0x1F7F: [1042976, 5, 0x1F81], ! 0x1F80: [1042976, 5, 0x1F81], ! 0x1F81: [1042976, 5, 0x1F81], ! 0x1F82: [1042976, 5, 0x1F81], ! 0x1F83: [1042976, 5, 0x1F81], ! 0x1F84: [1042976, 5, 0x1F81], ! 0x1F85: [1042976, 5, 0x1F81], ! 0x1F86: [1042976, 5, 0x1F81], ! 0x1F87: [1042976, 5, 0x1F81], ! 0x1F88: [1042976, 5, 0x1F81], ! 0x1F89: [1042976, 5, 0x1F81], ! 0x1F8A: [1042976, 5, 0x1F81], ! 0x1F8B: [1042976, 5, 0x1F81], ! 0x1F8C: [1042976, 5, 0x1F81], ! 0x1F8D: [1042976, 5, 0x1F81], ! 0x1F8E: [1042976, 5, 0x1F81], ! 0x1F8F: [1042976, 5, 0x1F81], ! 0x1F90: [1042976, 5, 0x1F81], ! 0x1F91: [1042976, 5, 0x1F81], ! 0x1F92: [1042976, 5, 0x1F81], ! 0x1F93: [1042976, 5, 0x1F81], ! 0x1F94: [1042976, 5, 0x1F81], ! 0x9EE: [1042976, 5, 0x1F81], ! 0x9EF: [1042976, 5, 0x1F81], # Pitcher ! 0x9a7: [1048128, 5, 0xFF6], ! 0xff6: [1048128, 5, 0xFF6], ! 0xff7: [1048128, 5, 0xFF6], ! 0xff8: [1048128, 5, 0xFF6], ! 0xff9: [1048128, 5, 0xFF6], ! 0x1f95: [1048128, 5, 0xFF6], ! 0x1f96: [1048128, 5, 0xFF6], ! 0x1f97: [1048128, 5, 0xFF6], ! 0x1f98: [1048128, 5, 0xFF6], ! 0x1f99: [1048128, 5, 0xFF6], ! 0x1f9a: [1048128, 5, 0xFF6], ! 0x1f9b: [1048128, 5, 0xFF6], ! 0x1f9c: [1048128, 5, 0xFF6], ! 0x1f9d: [1048128, 5, 0xFF6], ! 0x1f9e: [1048128, 5, 0xFF6], } --- 4,85 ---- import random ! # Baseid: ClilocBaseId, MaxQuantity, Empty Item Id, Fillable CONTAINERS = { ! 0x9c8: [1042965, 10, 0, False, ''], # Jug ! 0x99f: [1042959, 5, 0, False, ''], # Bottle of Ale ! 0x99b: [1042959, 5, 0, False, ''], # Bottle of Liquor ! 0x9c7: [1042959, 5, 0, False, ''], # Bottle of Wine # Ceramic Mugs ! 0x995: [1042982, 1, 0x995, True, ''], ! 0x996: [1042982, 1, 0x995, True, ''], ! 0x997: [1042982, 1, 0x995, True, ''], ! 0x998: [1042982, 1, 0x995, True, ''], ! 0x999: [1042982, 1, 0x995, True, ''], ! 0x9CA: [1042982, 1, 0x995, True, ''], ! ! # Skull Mugs ! 0xFFB: [1042988, 1, 0xFFB, True, ''], ! 0xFFC: [1042988, 1, 0xFFC, True, ''], ! 0xFFD: [1042988, 1, 0xFFD, True, ''], ! 0xFFE: [1042988, 1, 0xFFE, True, ''], # Pewter Mugs ! 0xFFF: [1042994, 1, 0xFFF, True, ''], ! 0x1000: [1042994, 1, 0x1000, True, ''], ! 0x1001: [1042994, 1, 0x1001, True, ''], ! 0x1002: [1042994, 1, 0x1002, True, ''], # Goblet ! 0x99A: [1043000, 1, 0x99A, True, ''], ! 0x9B3: [1043000, 1, 0x9B3, True, ''], ! 0x9BF: [1043000, 1, 0x9BF, True, ''], ! 0x9CB: [1043000, 1, 0x9CB, True, ''], # Glass Mug ! 0x1F7D: [1042976, 5, 0x1F81, True, 'cider'], # cider ! 0x1F7E: [1042976, 5, 0x1F82, True, 'cider'], # cider ! 0x1F7F: [1042976, 5, 0x1F83, True, 'cider'], # cider ! 0x1F80: [1042976, 5, 0x1F84, True, 'cider'], # cider ! 0x1F81: [1042976, 5, 0x1F81, True, ''], # empty ! 0x1F82: [1042976, 5, 0x1F82, True, ''], # empty ! 0x1F83: [1042976, 5, 0x1F83, True, ''], # empty ! 0x1F84: [1042976, 5, 0x1F84, True, ''], # empty ! 0x1F85: [1042976, 5, 0x1F81, True, 'liquor'], # liquor ! 0x1F86: [1042976, 5, 0x1F82, True, 'liquor'], # liquor ! 0x1F87: [1042976, 5, 0x1F83, True, 'liquor'], # liquor ! 0x1F88: [1042976, 5, 0x1F84, True, 'liquor'], # liquor ! 0x1F89: [1042976, 5, 0x1F81, True, 'milk'], # milk ! 0x1F8A: [1042976, 5, 0x1F82, True, 'milk'], # milk ! 0x1F8B: [1042976, 5, 0x1F83, True, 'milk'], # milk ! 0x1F8C: [1042976, 5, 0x1F84, True, 'milk'], # milk ! 0x1F8D: [1042976, 5, 0x1F81, True, 'wine'], # wine ! 0x1F8E: [1042976, 5, 0x1F82, True, 'wine'], # wine ! 0x1F8F: [1042976, 5, 0x1F83, True, 'wine'], # wine ! 0x1F90: [1042976, 5, 0x1F84, True, 'wine'], # wine ! 0x1F91: [1042976, 5, 0x1F81, True, 'water'], # water ! 0x1F92: [1042976, 5, 0x1F82, True, 'water'], # water ! 0x1F93: [1042976, 5, 0x1F83, True, 'water'], # water ! 0x1F94: [1042976, 5, 0x1F84, True, 'water'], # water ! 0x9EE: [1042976, 5, 0x1F82, True, 'ale'], # ale ! 0x9EF: [1042976, 5, 0x1F83, True, 'ale'], # ale # Pitcher ! 0x9a7: [1048128, 5, 0x9a7, True, ''], # empty ! 0x9ad: [1048128, 5, 0x9a7, True, ''], # milk ! 0xff6: [1048128, 5, 0xff6, True, ''], # empty ! 0xff7: [1048128, 5, 0xff7, True, ''], # empty ! 0xff8: [1048128, 5, 0xff7, True, 'water'], # water ! 0xff9: [1048128, 5, 0xff6, True, 'water'], # water ! 0x1f95: [1048128, 5, 0xff6, True, 'ale'], # ale ! 0x1f96: [1048128, 5, 0xff7, True, 'ale'], # ale ! 0x1f97: [1048128, 5, 0xff6, True, 'cider'], # cider ! 0x1f98: [1048128, 5, 0xff7, True, 'cider'], # cider ! 0x1f99: [1048128, 5, 0xff6, True, 'liquor'], # liquor ! 0x1f9a: [1048128, 5, 0xff7, True, 'liquor'], # liquor ! 0x1f9b: [1048128, 5, 0xff6, True, 'wine'], # wine ! 0x1f9c: [1048128, 5, 0xff7, True, 'wine'], # wine ! 0x1f9d: [1048128, 5, 0xff5, True, 'water'], # water ! 0x1f9e: [1048128, 5, 0xff7, True, 'water'], # water } *************** *** 100,112 **** if quantity == 0: ! return refill(char, item) else: ! return drink(char, item) # # Refill the container with something # ! def refill(char, item): ! return 0 # --- 107,213 ---- if quantity == 0: ! if CONTAINERS.has_key(item.id): ! cprops = CONTAINERS[item.id] ! ! if cprops[3]: ! char.socket.clilocmessage(500837) ! char.socket.attachtarget('beverage.refill_target', [item.serial]) ! return 1 ! return 0 else: ! return drink(char, item) ! ! # ! # Find a valid container item id for the given fluid ! # ! def updateItemIdFromFluid(item, fluid): ! if not FLUIDS.has_key(fluid): ! return ! ! origid = item.id ! ! # Search the container list ! for (key, value) in CONTAINERS.items(): ! # Refillable, EmptyId of the container are we, fluid is the same ! if value[3] and value[2] == origid and value[4] == fluid: ! item.id = key ! item.update() ! return True ! ! return False # # Refill the container with something # ! def refill_target(char, args, target): ! item = wolfpack.finditem(args[0]) ! if not item: ! return ! ! if not CONTAINERS.has_key(item.id): ! return ! ! cprops = CONTAINERS[item.id] ! ! if target.item: ! if not char.canreach(target.item, 3): ! char.socket.clilocmessage(1019045) ! return ! ! if CONTAINERS.has_key(target.item.id): ! quantity = 0 ! if target.item.hastag('quantity'): ! quantity = int(target.item.gettag('quantity')) ! ! fluid = '' ! if target.item.hastag('fluid'): ! fluid = str(target.item.gettag('fluid')) ! ! if quantity > 0 and FLUIDS.has_key(fluid): ! item.settag('fluid', fluid) ! ! # How much can we refill? ! if quantity > cprops[1]: ! quantity -= cprops[1] ! target.item.settag('quantity', quantity) ! target.item.resendtooltip() ! item.settag('quantity', cprops[1]) ! updateItemIdFromFluid(item, 'water') ! item.resendtooltip() ! ! # The source will be depleted ! else: ! item.settag('quantity', quantity) ! item.resendtooltip() ! ! cprop = CONTAINERS[target.item.id] ! if cprop[2] == 0: ! target.item.delete() ! else: ! target.item.id = cprop[2] ! target.item.update() ! target.item.deltag('quantity') ! target.item.deltag('fluid') ! target.item.resendtooltip() ! ! return # We refilled ! ! # A watersource ! if target.item.watersource: ! # Check if its depletable ! quantity = cprops[1] ! if target.item.hastag('quantity'): ! quantity = int(item.gettag('quantity')) ! ! if quantity > 0: ! item.settag('fluid', 'water') ! item.settag('quantity', quantity) ! updateItemIdFromFluid(item, 'water') ! item.resendtooltip() ! ! # Check if its a water source ! model = target.item.id ! ! # Maybe we should check the baseid of statics here to see if its a watersource # |