[wpdev-commits] xmlscripts/scripts/weapons blades.py,1.11,1.12
Brought to you by:
rip,
thiagocorrea
|
From: <dr...@pr...> - 2004-01-26 13:49:51
|
Update of /cvsroot/wpdev/xmlscripts/scripts/weapons In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27237/scripts/weapons Modified Files: blades.py Log Message: Slight tweaks, updates, syncs, etc. Split the lumberjacking code from weapons.blades to skills.lumberjacking. Later today I'll work on the rest of the potions. Index: blades.py =================================================================== RCS file: /cvsroot/wpdev/xmlscripts/scripts/weapons/blades.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** blades.py 14 Jan 2004 17:53:38 -0000 1.11 --- blades.py 26 Jan 2004 13:48:50 -0000 1.12 *************** *** 12,15 **** --- 12,16 ---- from wolfpack.consts import * from wolfpack.utilities import hex2dec + from skills.lumberjacking import * import wolfpack.utilities import whrandom *************** *** 18,28 **** # Lists of IDs blood = [ "122a", "122b", "122d", "122f" ] - trees = [] fish = [ 0x9cc, 0x9cd, 0x9ce, 0x9cf ] - def onLoad(): - # Load the list of valid trees just once - weapons.blades.trees = wolfpack.list( "IDS_TREE" ) - def onUse( char, item ): char.socket.clilocmessage( 0xF69A6 ) # What do you want to use this on? --- 19,24 ---- *************** *** 79,86 **** # Check for Trees ! if not is_tree( model ): char.socket.clilocmessage( 0x7A30E ) # You can't use a bladed item on that else: ! if not check_wood( target.pos ): char.clilocmessage( 0x7A7C4 ) # Cheaters never win. return --- 75,82 ---- # Check for Trees ! if not skills.lumberjacking.is_tree( model ): char.socket.clilocmessage( 0x7A30E ) # You can't use a bladed item on that else: ! if not skills.lumberjacking.check_wood( target.pos ): char.clilocmessage( 0x7A7C4 ) # Cheaters never win. return *************** *** 93,227 **** return else: ! hack_logs( char, target.pos ) # Swords and Fencing Weapons: Get kindling elif item.type == 1001 or item.type == 1005: ! hack_kindling( char, target.pos ) ! ! # Check for Wood at a specific position ! def check_wood( pos ): ! statics = wolfpack.statics( pos.x, pos.y, pos.map ) ! ! for item in statics: ! id = item[ "id" ] ! ! if is_tree( id ): ! return 1 ! ! # Check normal items ! dynamics = wolfpack.items( pos.x, pos.y, pos.map ) ! ! for item in dynamics: ! if is_tree( item.id ): ! return 1 ! ! return 0 ! ! # Delay for chopping trees and getting the logs ! def chop_delay( time, args ): ! char = args[0] ! pos = args[1] ! resource = args[2] ! amount = args[3] ! ! # Skill Check against LUMBERJACKING ! if not char.checkskill( LUMBERJACKING, LUMBERJACKING_MIN_SKILL, LUMBERJACKING_MAX_SKILL ): ! char.socket.clilocmessage( 0x7A30F, "", 0x3b2, 3, char ) # You hack at the tree for a while but fail to produce... ! return ! ! char.socket.clilocmessage( 0x7A312, "", 0x3b2, 3, char ) # You put some logs into your backpack ! ! # Create an item in my pack (logs to be specific) ! item = wolfpack.additem( "1be0" ) ! item.amount = 10 ! if not wolfpack.utilities.tobackpack( item, char ): ! item.update() ! ! # Create a resource item if neccesary ! if not resource: ! resource = wolfpack.additem( "1ea7" ) ! resource.name = 'Resource Item: logs' ! resource.settag( 'resourcecount', str( amount - 1 ) ) ! resource.settag( 'resource', 'logs' ) ! resource.visible = 0 # GM Visible only ! resource.moveto( pos ) ! resource.decay = 1 ! resource.decaytime = wolfpack.time.servertime() + ( LUMBERJACKING_REFILLTIME * 1000 ) ! resource.update() # Send to GMs ! else: ! resource.settag( 'resourcecount', amount - 1 ) ! ! return OK ! ! # Animation Sequence ! def chop_tree_two( time, args ): ! char = args[0] ! pos = args[1] ! # Turn to our lumberjacking position ! direction = char.directionto( pos ) ! if char.direction != direction: ! char.direction = direction ! char.updateflags() ! ! # Let him hack ! char.action( 0xd ) ! char.soundeffect( 0x13e ) ! return OK ! ! def chop_tree_three( time, args ): ! char = args[0] ! pos = args[1] ! # Turn to our lumberjacking position ! direction = char.directionto( pos ) ! if char.direction != direction: ! char.direction = direction ! char.updateflags() ! ! # Let him hack ! char.action( 0xd ) ! char.soundeffect( 0x13e ) ! return OK ! ! # HACK LOGS ! def hack_logs( char, pos ): ! # Try to find a resource item ! resource = None ! ! dynamics = wolfpack.items( pos.x, pos.y, pos.map ) ! ! for item in dynamics: ! if item.id == 0x1ea7 and item.hastag( 'resourcecount' ) and item.hastag( 'resource' ) and item.gettag( 'resource' ) == 'logs': ! ! # Check if the resource item didn't expire already (could be a bug!) ! if item.decaytime <= wolfpack.time.servertime(): ! item.delete() ! else: ! resource = item ! break ! ! # Default Range for each tree is 10 to 15 Logs ! if not resource: ! amount = whrandom.randint( LUMBERJACKING_MIN_LOGS, LUMBERJACKING_MAX_LOGS ) ! else: ! amount = int( resource.gettag( 'resourcecount' ) ) ! ! # No resource left to harvest? ! if amount < 1: ! char.socket.clilocmessage( 0x7A30D, "", 0x3b2, 3, char ) # There's not enough wood here to harvest. ! return ! ! # Turn to our lumberjacking position ! direction = char.directionto( pos ) ! if char.direction != direction: ! char.direction = direction ! char.updateflags() ! ! # Let him hack ! char.action( 0xd ) ! char.soundeffect( 0x13e ) ! ! wolfpack.addtimer( 2000, "weapons.blades.chop_tree_two", [char, pos] ) ! wolfpack.addtimer( 3500, "weapons.blades.chop_tree_three", [char, pos] ) ! wolfpack.addtimer( 4000, "weapons.blades.chop_delay", [char, pos, resource, amount ] ) ! return # CARVE CORPSE --- 89,96 ---- return else: ! skills.lumberjacking.hack_logs( char, target.pos ) # Swords and Fencing Weapons: Get kindling elif item.type == 1001 or item.type == 1005: ! skills.lumberjacking.hack_kindling( char, target.pos ) # CARVE CORPSE *************** *** 272,309 **** corpse.carve = '' - # HACK KINDLINGS - def hack_kindling( char, pos ): - if pos.distance( char.pos ) > 3: - char.socket.clilocmessage( 0x7A258 ) # You cannot reach that - return 1 - - direction = char.directionto( pos ) - if char.direction != direction: - char.direction = direction - char.updateflags() - - # N O T E: For anti-cheat prevention we have to check - # if the statics REALLY contain the tree - - # Let's add some Kindling - item = wolfpack.additem( "de1" ) - if not wolfpack.utilities.tobackpack( item, char ): - item.update() - - # Let him hack - char.action( 0x9 ) - char.soundeffect( 0x13e ) - char.socket.clilocmessage( 0x7A30B ) # You put some kindlings in your pack - - # Is "model" a Tree art-tile? - def is_tree( model ): - # List consists of hexadecimal integers - for tree in trees: - tree = hex2dec( tree ) - if tree == model: - return 1 - - return 0 - # CUT FISH def cut_fish( char, item ): --- 141,144 ---- |