def commandRestock(socket, cmd, args): if len(args) == 0: socket.sysmessage('Usage: restock <baseid> OR restock all') return baseid = args.lower() counter = 0 chars = wolfpack.chariterator() char = chars.first # Now lets check the args. I think is better to check here than check in NPC Loop if baseid == 'all': while char: if char.hastag("spawner"): char.delete() counter += 1 char = chars.next else: while char: if char.baseid.lower() == baseid: if char.hastag("spawner"): char.delete() counter += 1 char = chars.next socket.sysmessage(str(counter) + " NPCs restocked in the World")
def goname(socket, command, arguments): if len(arguments) == 0: socket.sysmessage('Usage: goname <name>') return chars = wolfpack.chariterator() char = chars.first found = None name = hash(arguments.lower()) while char: if hash(char.name.lower()) == name: found = char break char = chars.next if not found: socket.sysmessage('A character with the given name was not found.') else: socket.sysmessage("Going to character '%s' [Serial: 0x%x]." % (found.name, found.serial)) pos = found.pos socket.player.removefromview() socket.player.moveto(pos) socket.player.update() socket.resendworld()
def commandRestock(socket, cmd, args): if len(args) == 0: socket.sysmessage('Usage: restock <baseid> OR restock all') return baseid = args.lower() counter = 0 chars = wolfpack.chariterator() char = chars.first # Now lets check the args. I think is better to check here than check in NPC Loop if baseid == 'all': while char: if char.hastag( "spawner" ): char.delete() counter += 1 char = chars.next else: while char: if char.baseid.lower() == baseid: if char.hastag( "spawner" ): char.delete() counter += 1 char = chars.next socket.sysmessage( str(counter) + " NPCs restocked in the World" )
def goname(socket, command, arguments): if len(arguments) == 0: socket.sysmessage("Usage: goname <name>") return chars = wolfpack.chariterator() char = chars.first name = hash(arguments.lower()) found = [] while char: if hash(char.name.lower()) == name: if not char.rank > socket.player.rank: found.append(char) char = chars.next if socket.hastag("goname"): i = socket.gettag("goname") + 1 if i >= len(found): # No more chars with the same name, start from the beginning i = 0 socket.settag("goname", i) else: socket.settag("goname", 0) i = 0 if len(found) == 0: socket.sysmessage("A character with the given name was not found.") else: pos = found[i].pos if pos.map == 0xFF: if found[i].npc: stablemaster = wolfpack.findobject(found[i].stablemaster) else: stablemaster = None if not stablemaster: socket.sysmessage( "Not going to character '%s' [Serial: 0x%x]. They are on the internal map." % (found[i].name, found[i].serial) ) else: socket.sysmessage( "Character '%s' [Serial: 0x%x] is stabled in object 0x%x." % (found[i].name, found[i].serial, stablemaster.serial) ) else: socket.sysmessage("Going to character '%s' [Serial: 0x%x]." % (found[i].name, found[i].serial)) socket.player.removefromview() socket.player.moveto(pos) socket.player.update() socket.resendworld()
def loyaltyexp(obj, args): if args[0] != magic_pets: return # The scripts have been reloaded wolfpack.addtimer(CHECKINTERVAL, loyaltyexp, [magic_pets], False) iterator = wolfpack.chariterator() char = iterator.first while char: if not char.npc: # Do not forget the iteration step char = iterator.next continue # Access char properties here if char.tamed: char.hunger = 20 if not char.hastag("loyalty"): char.settag("loyalty", 11) loyalty = char.gettag("loyalty") owner = char.owner if owner and owner.gm: return False if loyalty > 0 and char.pos.map != 0xFF: torelease = False loyalty_new = loyalty - 1 if loyalty_new < 1: torelease = True else: char.settag("loyalty", loyalty_new) if loyalty_new == 1: # Confused char.say(1043270, unicode(char.name)) # * ~1_NAME~ looks around desperately * char.sound(SND_IDLE) if torelease: char.say( 1043255, unicode(char.name) ) # ~1_NAME~ appears to have decided that is better off without a master! char.settag("loyalty", 11) # Wonderfully happy # #c.IsBonded = false; # #c.BondingBegin = DateTime.MinValue; # #c.OwnerAbandonTime = DateTime.MinValue; release(char) # not tamed else: # Animals in houses/multis if char.multi: if not char.dead: if char.hastag("removestep"): if char.gettag("removestep") >= 20: char.delete() else: char.settag("removestep", char.gettag("removestep") + 1) else: char.settag("removestep", 1) else: if char.hastag("removestep"): char.deltag("removestep") char = iterator.next return
def gobaseid(socket, command, arguments): if len(arguments) == 0: socket.sysmessage('Usage: gobaseid <baseid>') return items = wolfpack.itemiterator() item = items.first baseid = hash(arguments.lower()) found = [] while item: if hash(item.baseid.lower()) == baseid: found.append( item ) item = items.next chars = wolfpack.chariterator() char = chars.first while char: if hash(char.baseid.lower()) == baseid: found.append( char ) char = chars.next if socket.hastag( "gobaseid" ): i = socket.gettag( "gobaseid" ) + 1 if i >= len(found): # No more items with the same baseid, start from the beginning i = 0 socket.settag( "gobaseid", i ) else: socket.settag( "gobaseid", 0 ) i = 0 if len(found) == 0: socket.sysmessage('An object with the given baseid was not found.') return False object = found[i] uid = hex2dec(object.serial) # Item if uid > 0x40000000: container = object.getoutmostitem() if container.container: container = container.container if object.name != '': socket.sysmessage("Going to item '%s' [Serial: 0x%x; Top: 0x%x]." % (object.name, object.serial, container.serial)) else: socket.sysmessage("Going to item [Serial: 0x%x; Top: 0x%x]." % (object.serial, container.serial)) pos = container.pos socket.player.removefromview() socket.player.moveto(pos) socket.player.update() socket.resendworld() if object.container: socket.sendobject(object.container) if object.container.isitem(): socket.sendcontainer(object.container) # Char elif uid > 0: if object.rank > socket.player.rank: return False socket.sysmessage('Going to char 0x%x.' % (uid)) pos = object.pos socket.player.removefromview() socket.player.moveto(pos) socket.player.update() socket.resendworld()
def loyaltyexp(obj, args): if args[0] != magic_pets: return # The scripts have been reloaded wolfpack.addtimer(CHECKINTERVAL, loyaltyexp, [magic_pets], False) iterator = wolfpack.chariterator() char = iterator.first while char: if not char.npc: # Do not forget the iteration step char = iterator.next continue # Access char properties here if char.tamed: char.hunger = 20 if not char.hastag('loyalty'): char.settag('loyalty', 11) loyalty = char.gettag('loyalty') owner = char.owner if owner and owner.gm: return False if loyalty > 0 and char.pos.map != 0xFF: torelease = False loyalty_new = loyalty - 1 if loyalty_new < 1: torelease = True else: char.settag('loyalty', loyalty_new) if loyalty_new == 1: # Confused char.say(1043270, unicode( char.name)) # * ~1_NAME~ looks around desperately * char.sound(SND_IDLE) if torelease: char.say( 1043255, unicode(char.name) ) # ~1_NAME~ appears to have decided that is better off without a master! char.settag('loyalty', 11) # Wonderfully happy # #c.IsBonded = false; # #c.BondingBegin = DateTime.MinValue; # #c.OwnerAbandonTime = DateTime.MinValue; release(char) # not tamed else: # Animals in houses/multis if char.multi: if not char.dead: if char.hastag("removestep"): if char.gettag("removestep") >= 20: char.delete() else: char.settag("removestep", char.gettag("removestep") + 1) else: char.settag("removestep", 1) else: if char.hastag("removestep"): char.deltag("removestep") char = iterator.next return