[wpdev-commits] xmlscripts/scripts key.py,1.3,1.4 lock.py,1.4,1.5
Brought to you by:
rip,
thiagocorrea
|
From: <dar...@pr...> - 2004-01-26 14:52:43
|
Update of /cvsroot/wpdev/xmlscripts/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9172 Modified Files: key.py lock.py Log Message: Improved keys and locks. Index: key.py =================================================================== RCS file: /cvsroot/wpdev/xmlscripts/scripts/key.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** key.py 25 Jan 2004 00:45:38 -0000 1.3 --- key.py 25 Jan 2004 20:26:54 -0000 1.4 *************** *** 1,12 **** - # 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): --- 1,70 ---- from wolfpack.consts import * import wolfpack ! from wolfpack.gumps import cGump import random ! def gump_response(char, args, response): ! if len(args) < 1: ! return ! ! key = wolfpack.finditem(args[0]) ! ! if not char.canreach(key, 5): ! char.socket.clilocmessage(501661) ! return ! ! # Rename ! new_name = response.text[1][:30] # 30 Chars max. ! key.name = new_name ! ! # Rekey ! if char.gm: ! new_lock = response.text[2] ! ! if len(new_lock) != 0: ! key.settag(new_lock) ! char.socket.sysmessage('This key now unlocks:' + new_lock) ! else: ! key.deltag('lock') ! char.socket.sysmessage('You erase the lock information.') ! ! def rename_key(char, key): ! ! # Build the lock gump ! gump = cGump(x=100, y=100, callback="key.gump_response") ! gump.setArgs([key.serial]) ! ! # Renaming, blanking and modification of keys allowed for gms ! gump.addBackground(id=0x2436, width=425, height=285) ! ! if char.gm: ! text = '<basefont color="#FECECE"><h3>Manage Key</h3><br><basefont color="#FEFEFE">This dialog will help you to manage or rename this key.' ! else: ! text = '<basefont color="#FECECE"><h3>Manage Key</h3><br><basefont color="#FEFEFE">This dialog will help you to rename this key.' ! ! gump.addHtmlGump(x=20, y=20, width=410, height=90, html=text) ! ! gump.addText(x=20, y=65, text='The name of this key:', hue=0x835) ! gump.addResizeGump(x=20, y=88, id=0xBB8, width=200, height=25) ! gump.addInputField(x=25, y=90, width=190, height=20, hue=0x834, id=1, starttext=key.name) ! ! # InputField for the key id ! if char.gm: ! lock = '' ! if key.hastag('lock'): ! lock = str(key.gettag('lock')) ! ! gump.addText(x=235, y=65, text='The lock id of this key:', hue=0x835) ! gump.addResizeGump(x=235, y=88, id=0xBB8, width=160, height=25) ! gump.addInputField(x=240, y=90, width=150, height=20, hue=0x834, id=2, starttext=lock) ! ! gump.addText(x=50, y=130, text='Modify key', hue=0x835) ! gump.addButton(x=20, y=130, up=0x26af, down=0x26b1, returncode=1) ! ! gump.addText(x=50, y=170, text='Cancel', hue=0x835) ! gump.addButton(x=20, y=170, up=0x26af, down=0x26b1, returncode=0) ! ! gump.send(char) def lock_response(char, args, target): *************** *** 24,31 **** return - # a) Targetted a lockable item if target.item == key: ! char.socket.sysmessage('rename key') ! # Gump... elif 'lock' in target.item.events: --- 82,87 ---- return if target.item == key: ! rename_key(char,key) elif 'lock' in target.item.events: *************** *** 33,37 **** target.item.deltag('locked') else: ! target.item.settag('locked','1') char.soundeffect(0x241) --- 89,93 ---- target.item.deltag('locked') else: ! target.item.settag('locked',1) char.soundeffect(0x241) *************** *** 92,95 **** --- 148,155 ---- tooltip.add(0xF9060 + item.id, '') + # The user defined name + if len(item.name) != 0: + tooltip.add(1050045, " \t" + item.name + "\t ") + # Add the lock id for gms if char.gm: Index: lock.py =================================================================== RCS file: /cvsroot/wpdev/xmlscripts/scripts/lock.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** lock.py 25 Jan 2004 00:45:39 -0000 1.4 --- lock.py 25 Jan 2004 20:26:54 -0000 1.5 *************** *** 157,188 **** wolfpack.registercommand("lock", commandLock) ! # ! # Event for Locking Items ! # ! def onUse( char, item ): ! events = item.events ! if not item.hastag( 'lock' ): ! return 0 ! lock = item.gettag( 'lock' ) ! ! if lock != 'magic': ! if item.hastag('locked'): ! locked = int(item.gettag('locked')) ! else: ! locked = 0 ! ! if locked == 0: ! return 0 ! ! # Search for a key in the users backpack ! #backpack = char.getbackpack() ! ! #if searchkey(backpack, lock): ! # if 'door' in events: ! # char.message(501282) # quickly open / relock ! # return 0 ! ! char.message(502503) # Thats locked ! return 1 --- 157,203 ---- wolfpack.registercommand("lock", commandLock) ! def searchkey(item, lock): ! # It's a key. ! if 'key' in item.events and item.hastag('lock'): ! if lock == str(item.gettag('lock')): ! return 1 ! for subitem in item.content: ! if searchkey(subitem, lock): ! return 1 ! return 0 ! ! def onUse(char, item): ! # The item is not locked ! if not item.hastag('lock'): ! return 0 ! ! # The magic lock spell has the lock id 'magic' ! lock = str(item.gettag('lock')) ! locked = 0 ! ! if item.hastag('locked'): ! locked = int(item.gettag('locked')) ! ! # For magic locks, the locked flag is irrelevant ! if lock != 'magic' and locked == 0: ! return 0 ! ! # GMs ignore locks but their access should be logged ! if char.gm: ! char.socket.clilocmessage(501281) ! return 0 ! ! # Only doors can be opened without unlocking them ! # if the user has the key in his posession. ! if 'door' in item.events: ! if searchkey(char.getbackpack(), lock): ! char.socket.clilocmessage(501282) ! return 0 ! ! char.socket.clilocmessage(500788) ! else: ! char.socket.clilocmessage(501746) ! ! return 1 \ No newline at end of file |