Update of /cvsroot/wpdev/xmlscripts/scripts/magic
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27142/magic
Modified Files:
__init__.py circle4.py circle5.py circle6.py circle7.py
runebook.py spell.py
Log Message:
fixes for runebooks
Index: runebook.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/scripts/magic/runebook.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** runebook.py 26 Sep 2004 16:17:27 -0000 1.8
--- runebook.py 27 Sep 2004 22:33:22 -0000 1.9
***************
*** 7,16 ****
import wolfpack
import magic
import magic.spell
from wolfpack.gumps import cGump
from magic.rune import isrune
! from magic.utilities import fizzle, MODE_BOOK
! import magic.utilities
import whrandom
import wolfpack.utilities
--- 7,18 ----
import wolfpack
+ from wolfpack import tr
import magic
import magic.spell
from wolfpack.gumps import cGump
+ import magic
from magic.rune import isrune
! import magic.scroll
! from magic.utilities import fizzle, MODE_BOOK, hasSpell
import whrandom
import wolfpack.utilities
***************
*** 37,71 ****
def onDropOnItem( book, item ):
! if not isrunebook( book ):
! return False
! if not isrune( item ):
! return False
! if( item.hastag( "marked" ) != 1 ):
! return False
!
! # initialize rune serials to -1 if there's no rune
! # should not occur - will be removed later
! for i in range( 0, 16 ):
! if not book.hastag( "rune %i" % i ):
! book.settag( "rune %i" % i, -1 )
!
! # rune serials
! runes = [ -1 ] * 16
! for i in range( 0, 16 ):
! runes[ i ] = int( book.gettag( "rune %i" % i ) )
! i = 0
! while( runes[ i ] > -1 and i < 16 ):
! i = i + 1
! # runebook is full
! if( i > 15 ):
! # can we access the char.socket ?
! # "This runebook is full."
! #char.socket.clilocmessage( 502401 )
! return False
! book.settag( "rune %i" % i, int( item.serial ) )
! # insert rune - is runebook a container ?
! if book.type == 1:
! wolfpack.utilities.tocontainer( item, book )
! item.update()
return True
--- 39,106 ----
def onDropOnItem( book, item ):
! char = item.container
!
! if isrunebook( book ):
! if isrune(item) and item.hastag('marked'):
! # initialize rune serials to -1 if there's no rune
! # should not occur - will be removed later
! for i in range( 0, 16 ):
! if not book.hastag( "rune %i" % i ):
! book.settag( "rune %i" % i, -1 )
!
! # rune serials
! runes = [ -1 ] * 16
! for i in range( 0, 16 ):
! runes[ i ] = int( book.gettag( "rune %i" % i ) )
! i = 0
! while( runes[ i ] > -1 and i < 16 ):
! i = i + 1
! # runebook is full
! if( i > 15 ):
! # can we access the char.socket ?
! # "This runebook is full."
! if char.socket:
! char.socket.clilocmessage( 502401 )
! char.getbackpack().additem(item)
! item.pos = book.pos
! item.pos.z += 1
! item.update()
! return True
!
! book.settag( "rune %i" % i, int( item.serial ) )
!
! # insert rune - is runebook a container ?
! wolfpack.utilities.tocontainer( item, book )
! item.update()
! return True
!
! # Recall Scrolls for recharging
! elif item.hasscript('magic.scroll'):
! try:
! spellid = magic.scroll.calcSpellId(item)
!
! # Recall Scroll
! if spellid + 1 == 32:
! charges = item.amount
! maxcharges = book.gettag('maxcharges') - book.gettag('charges')
!
! if maxcharges > 0:
! charges = min(charges, maxcharges)
! book.settag('charges', book.gettag('charges') + charges)
!
! if charges >= item.amount:
! item.delete()
! return True
! else:
! item.amount -= charges
! item.update()
! item.resendtooltip()
! except:
! pass
!
! char.getbackpack().additem(item)
! item.pos = book.pos
! item.pos.z += 1
! item.update()
return True
***************
*** 156,161 ****
# rename button return code = 1000
! runebook.addButton( 130, 20, 2472, 2473, 1000 )
! runebook.addText( 158, 22, "Rename Book" )
# next page - top right corner
--- 191,196 ----
# rename button return code = 1000
! #runebook.addButton( 130, 20, 2472, 2473, 1000 )
! #runebook.addText( 158, 22, "Rename Book" )
# next page - top right corner
***************
*** 344,347 ****
--- 379,394 ----
char.socket.sysmessage( "runebook script error." )
return False
+
+ if not char.gm:
+ if char.iscriminal():
+ if char.socket:
+ char.socket.clilocmessage(1005561)
+ return False
+
+ if char.attacktarget:
+ if char.socket:
+ char.socket.clilocmessage(1005564)
+ return False
+
location = rune.gettag('location')
location = location.split(",")
***************
*** 374,379 ****
# recall spell to the selected rune
def recall1( self, args ):
- if( len( args ) < 2 ):
- return 1
char = wolfpack.findchar( args[ 0 ] )
rune = wolfpack.finditem( args[ 1 ] )
--- 421,424 ----
***************
*** 381,436 ****
if not char:
return False
- if not rune:
- char.socket.sysmessage( "runebook script error." )
- return False
- # Check for Recall
- if not magic.utilities.hasSpell(char, 32):
- return False
! location = rune.gettag( 'location' )
! location = location.split(",")
! location = wolfpack.coord(int(location[0]), int(location[1]), int(location[2]), int(location[3]))
!
! region = None
! region = wolfpack.region(char.pos.x, char.pos.y, char.pos.map)
!
! if region and region.norecallout:
! char.message(501802)
! fizzle(char)
! return False
! region = None
! region = wolfpack.region(location.x, location.y, location.map)
!
! if not location.validspawnspot():
! char.message(501942)
! fizzle(char)
! return False
!
! if region and region.norecallin:
! char.message(1019004)
! fizzle(char)
! return False
!
! # cast spell
! if( char.mana < 11 ):
! char.socket.sysmessage( "You lack the mana to recall." )
return False
! # Insert link to Recall Spell!
! char.socket.sysmessage( "not implemented yet" )
!
return True
def gate( self, args ):
- if( len( args ) < 2 ):
- return 1
char = wolfpack.findchar( args[ 0 ] )
rune = wolfpack.finditem( args[ 1 ] )
if not char:
! return 1
if not rune:
! char.socket.sysmessage( "runebook script error." )
! return 1
! # Insert link to Gate Travel Spell!
! char.socket.sysmessage( "not implemented yet" )
! return 1
--- 426,448 ----
if not char:
return False
! if not rune:
! char.socket.sysmessage( "Missing recall rune." )
return False
! magic.castSpell( char, 32, MODE_BOOK, args = [], target = rune )
return True
def gate( self, args ):
char = wolfpack.findchar( args[ 0 ] )
rune = wolfpack.finditem( args[ 1 ] )
+
if not char:
! return False
!
if not rune:
! char.socket.sysmessage( "Missing recall rune." )
! return False
!
! magic.castSpell( char, 52, MODE_BOOK, args = [], target = rune )
! return True
Index: spell.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/scripts/magic/spell.py,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** spell.py 27 Sep 2004 14:37:26 -0000 1.28
--- spell.py 27 Sep 2004 22:33:22 -0000 1.29
***************
*** 51,55 ****
return
else:
! target = None
# item
--- 51,55 ----
return
else:
! target = args[3]
# item
***************
*** 64,68 ****
item = None
! args[0].cast(char, args[1], args[2], args[3], item)
# Basic Spell Class
--- 64,68 ----
item = None
! args[0].cast(char, args[1], args[2], target, item)
# Basic Spell Class
***************
*** 179,182 ****
--- 179,187 ----
char.log(LOG_MESSAGE, "Casting spell %s from %s.\n" % (self.__class__.__name__, source))
+ if target and type(target).__name__ == 'wpitem':
+ target = target.serial
+ elif target and type(target).__name__ == 'wpchar':
+ target = target.serial
+
char.addtimer(self.calcdelay(char, mode), 'magic.spell.callback', [self, mode, args, target, item], 0, 0, "cast_delay")
return 1
***************
*** 431,435 ****
# A target has been supplied
else:
! char.message('target has been supplied')
def target(self, char, mode, targettype, target, args, item):
--- 436,441 ----
# A target has been supplied
else:
! targetwrapper = TargetWrapper(target)
! magic.target_response(char, [self, mode, args, item], targetwrapper)
def target(self, char, mode, targettype, target, args, item):
***************
*** 442,445 ****
--- 448,469 ----
pass
+ class TargetWrapper:
+ def __init__(self, obj):
+ if type(obj).__name__ == 'wpitem':
+ self.item = obj
+ self.char = None
+ self.pos = obj.pos
+ self.model = obj.id
+ elif type(obj).__name__ == 'wpchar':
+ self.item = None
+ self.char = obj
+ self.pos = obj.pos
+ self.model = 0
+ else:
+ self.item = None
+ self.char = None
+ self.pos = obj
+ self.model = 0
+
class CharEffectSpell (Spell):
def __init__(self, circle):
Index: circle5.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/scripts/magic/circle5.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** circle5.py 10 Sep 2004 16:48:42 -0000 1.23
--- circle5.py 27 Sep 2004 22:33:22 -0000 1.24
***************
*** 20,24 ****
return
else:
! return Spell.cast(self, char, mode)
def target(self, char, mode, targettype, target, args, item):
--- 20,24 ----
return
else:
! return Spell.cast(self, char, mode, args, target, item)
def target(self, char, mode, targettype, target, args, item):
***************
*** 329,333 ****
char.socket.clilocmessage(1049645)
return
! return Spell.cast(self, char, mode)
def target(self, char, mode, targettype, target, args, item):
--- 329,333 ----
char.socket.clilocmessage(1049645)
return
! return Spell.cast(self, char, mode, args, target, item)
def target(self, char, mode, targettype, target, args, item):
Index: circle6.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/scripts/magic/circle6.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** circle6.py 1 Sep 2004 23:45:59 -0000 1.12
--- circle6.py 27 Sep 2004 22:33:22 -0000 1.13
***************
*** 105,109 ****
return
! return Spell.cast(self, char, mode)
def target(self, char, mode, targettype, target, args, item):
--- 105,109 ----
return
! return Spell.cast(self, char, mode, args, target, item)
def target(self, char, mode, targettype, target, args, item):
Index: circle7.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/scripts/magic/circle7.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** circle7.py 22 Sep 2004 07:37:46 -0000 1.16
--- circle7.py 27 Sep 2004 22:33:22 -0000 1.17
***************
*** 134,138 ****
return
! return Spell.cast(self, char, mode)
def target(self, char, mode, targettype, target, args, item):
--- 134,138 ----
return
! return Spell.cast(self, char, mode, args, target, item)
def target(self, char, mode, targettype, target, args, item):
Index: circle4.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/scripts/magic/circle4.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** circle4.py 16 Sep 2004 16:42:28 -0000 1.15
--- circle4.py 27 Sep 2004 22:33:22 -0000 1.16
***************
*** 121,125 ****
return
! return Spell.cast(self, char, mode)
def target(self, char, mode, targettype, target, args, item):
--- 121,125 ----
return
! return Spell.cast(self, char, mode, args, target, item)
def target(self, char, mode, targettype, target, args, item):
Index: __init__.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/scripts/magic/__init__.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** __init__.py 24 Sep 2004 11:07:04 -0000 1.18
--- __init__.py 27 Sep 2004 22:33:22 -0000 1.19
***************
*** 102,106 ****
char.socket.clilocmessage(500446)
return
! if not char.canreach(target, spell.range):
if char.socket:
char.socket.clilocmessage(500237)
--- 102,106 ----
char.socket.clilocmessage(500446)
return
! if not char.canreach(target.char, spell.range):
if char.socket:
char.socket.clilocmessage(500237)
***************
*** 120,124 ****
char.socket.clilocmessage(500237)
return
! if not char.canreach(target, spell.range):
if char.socket:
char.socket.clilocmessage(500237)
--- 120,124 ----
char.socket.clilocmessage(500237)
return
! if not char.canreach(target.item, spell.range):
if char.socket:
char.socket.clilocmessage(500237)
***************
*** 146,150 ****
char.socket.clilocmessage(500446)
return
! if not char.canreach(target, spell.range):
if char.socket:
char.socket.clilocmessage(500237)
--- 146,150 ----
char.socket.clilocmessage(500446)
return
! if not char.canreach(target.pos, spell.range, target.model):
if char.socket:
char.socket.clilocmessage(500237)
|