[wpdev-commits] xmlscripts/scripts key.py,1.1,1.2
Brought to you by:
rip,
thiagocorrea
|
From: <dar...@pr...> - 2004-01-27 13:17:06
|
Update of /cvsroot/wpdev/xmlscripts/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1418 Modified Files: key.py Log Message: Did key copying... Index: key.py =================================================================== RCS file: /cvsroot/wpdev/xmlscripts/scripts/key.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** key.py 22 Jan 2004 03:51:22 -0000 1.1 --- key.py 24 Jan 2004 22:33:25 -0000 1.2 *************** *** 2,13 **** # TODO: implementation of renaming and unlocking/locking etc. import wolfpack import wolfpack.gumps def onLoad(): pass def onUse(char, key): ! char.message('A shiny key!') return 1 --- 2,62 ---- # TODO: implementation of renaming and unlocking/locking etc. + from wolfpack.consts import * import wolfpack import wolfpack.gumps + import random def onLoad(): pass + def lock_response(char, args, target): + return + + def copy_response(char, args, target): + if len(args) != 1: + return + + key = wolfpack.finditem(args[0]) + if not key or not char.canreach(key,5): + char.socket.clilocmessage(501661) + return + + # Check if the targetted item is a key + if not target.item or not 'key' in target.item.events: + char.socket.clilocmessage(501679) + return + + # Also a blank key? + if not target.item.hastag('lock'): + char.socket.clilocmessage(501675) + return + + # Check if the player can reach the item + if not char.canreach(target.item,5): + char.socket.clilocmessage(501661) + return + + # Tinkering check (15%-30%, 25% chance of loosing the key on failure) + if char.checkskill(TINKERING, 150, 300): + key.settag('lock',target.item.gettag('lock')) + char.socket.clilocmessage(501676) + else: + char.socket.clilocmessage(501677) + + # 25% chance of destroying the blank key + if random.randint(1,4) == 1: + char.socket.clilocmessage(501678) + key.remove() + def onUse(char, key): ! # Does this key open a lock? ! if not key.hastag('lock'): ! # The key is blank so we wan't to make a copy of it ! char.socket.clilocmessage(501663) ! char.socket.attachtarget('key.copy_response',[key.serial]) ! else: ! char.socket.clilocmessage(501662) ! char.socket.attachtarget('key.lock_response',[key.serial]) ! return 1 *************** *** 17,26 **** # Add the lock id for gms if char.gm: - lock = 'None' - if item.hastag('lock'): lock = str(item.gettag('lock')) ! ! tooltip.add(1050045, " \t" + "Lock: " + lock + "\t ") tooltip.send(char) --- 66,74 ---- # Add the lock id for gms if char.gm: if item.hastag('lock'): lock = str(item.gettag('lock')) ! tooltip.add(1050045, " \t" + "Lock: " + lock + "\t ") ! else: ! tooltip.add(1050045, " \tThis key is blank\t ") tooltip.send(char) |