示例#1
0
def chainpotiontimer( cserial, iserial, bserial, outradius ):
	char = wolfpack.findchar( cserial )
	item = wolfpack.finditem( iserial )
	bomb = wolfpack.finditem( bserial )

	if not item or not bomb:
		return False

	if bomb.hastag( 'exploding' ):
		return False

	# Doing error checks first, makes it faster
	if not checkLoS( item, bomb, outradius ):
		return False

	potiontype = getPotionType( bomb )

	if not potiontype in [11, 12, 13]:
		return False

	bomb.settag( 'exploding', cserial )

	if isPotionkeg( bomb ) and int( bomb.gettag( 'kegfill' ) ) >= 1:
		bomb.addtimer( randint( 1000, 2250 ), potioncountdown, [ char.serial, 10, int( bomb.gettag( 'kegfill' ) ) ] )
	else:
		bomb.addtimer( randint( 1000, 2250 ), potioncountdown, [ char.serial, 0, bomb.amount ] )
	return True
def chainpotiontimer( cserial, iserial, bserial, outradius ):
	char = wolfpack.findchar( cserial )
	item = wolfpack.finditem( iserial )
	bomb = wolfpack.finditem( bserial )

	if not item or not bomb:
		return False

	if bomb.hastag( 'exploding' ):
		return False

	# Doing error checks first, makes it faster
	if not checkLoS( item, bomb, outradius ):
		return False

	potiontype = getPotionType( bomb )

	if not potiontype in [11, 12, 13]:
		return False

	bomb.settag( 'exploding', cserial )

	if isPotionkeg( bomb ) and int( bomb.gettag( 'kegfill' ) ) >= 1:
		bomb.addtimer( randint( 1000, 2250 ), "potions.explosion.potioncountdown", [ char.serial, 10, int( bomb.gettag( 'kegfill' ) ) ] )
	else:
		bomb.addtimer( randint( 1000, 2250 ), "potions.explosion.potioncountdown", [ char.serial, 0, bomb.amount ] )
	return True
示例#3
0
def addPotion(player, plant, potiontypes):
    # Try to find an item to pour into the plant
    potion = None
    backpack = player.getbackpack()
    for item in backpack.content:
        if item.hasscript("potions"):
            potiontype = potions.utilities.getPotionType(item)
            if potiontype in potiontypes:
                potion = item
                break
        elif potionkeg.isPotionkeg(item) and item.gettag("kegfill"):
            potiontype = potions.utilities.getPotionType(item)
            if potiontype in potiontypes:
                potion = item
                break

    if potion:
        plants.plant.pour(player, plant, potion)
    else:
        # If we CAN apply a potion of the type, show a target
        if plants.plant.applyPotion(player, plant, potiontypes[0], True):
            player.socket.clilocmessage(1061884)  # You don't have any strong potions of that type in your pack.
            player.socket.clilocmessage(
                1060808, "#%u" % plants.plant.getStatusCliloc(plant)
            )  # Target the container you wish to use to water the ~1_val~.
            player.socket.attachtarget("plants.plant.pour_target", [plant.serial])

            # otherwise just print a message
        else:
            plant.say(
                1053065, "", "", False, 0x3B2, player.socket
            )  # The plant is already soaked with this type of potion!

    send(player, plant)  # Resend the main gump
示例#4
0
def pour(player, plant, item):
	status = getStatus(plant)
	
	if status >= STATUS_DEAD:
		return
		
	if status == STATUS_DECORATIVE:
		plant.say(1053049, '', '', False, 0x3b2, player.socket) # This is a decorative plant, it does not need watering!
		return
		
	if not checkAccess(player, plant):
		plant.say(1061856, '', '', False, 0x3b2, player.socket)
		return

	# Beverage -> Water
	if item.hasscript('beverage'):
		# It's not water or doesn't have enough content
		if item.gettag('fluid') != 'water' or not item.gettag('quantity'):
			plant.say(1053069, '', '', False, 0x3b2, player.socket) # You can't use that on a plant!
		else:
			beverage.consume(item) # Consume one use
			setWater(plant, getWater(plant) + 1) # Give one more water unit
			plant.resendtooltip()
			
			player.soundeffect(0x4e) # Soundeffect
			plant.say(1061858, '', '', False, 0x3b2, player.socket) # You soften the dirt with water.			
			
	# Potion
	elif item.hasscript('potions'):
		potiontype = potions.utilities.getPotionType(item)
		if applyPotion(player, plant, potiontype):			
			potions.utilities.consumePotion(player, item)
			player.soundeffect(0x240)
			
	# Potion Keg
	elif potionkeg.isPotionkeg(item):
		# Empty potion kegs won't work
		if not item.gettag('kegfill'):
			plant.say(1053069, '', '', False, 0x3b2, player.socket) # You can't use that on a plant!
		else:
			potiontype = potions.utilities.getPotionType(item)
			if applyPotion(player, plant, potiontype):
				item.settag('kegfill', item.gettag('kegfill') - 1)
				item.resendtooltip()
				player.soundeffect(0x240)
				
	# Something Else
	else:
		plant.say(1053069, '', '', False, 0x3b2, player.socket) # You can't use that on a plant!	
示例#5
0
def pour(player, plant, item):
	status = getStatus(plant)
	
	if status >= STATUS_DEAD:
		return

	if status == STATUS_DECORATIVE:
		plant.say(1053049, '', '', False, 0x3b2, player.socket) # This is a decorative plant, it does not need watering!
		return

	if not checkAccess(player, plant):
		plant.say(1061856, '', '', False, 0x3b2, player.socket)
		return

	# Beverage -> Water
	if item.hasscript('beverage'):
		# It's not water or doesn't have enough content
		if item.gettag('fluid') != 'water' or not item.gettag('quantity'):
			plant.say(1053069, '', '', False, 0x3b2, player.socket) # You can't use that on a plant!
		else:
			beverage.consume(item) # Consume one use
			setWater(plant, getWater(plant) + 1) # Give one more water unit
			plant.resendtooltip()
			
			player.soundeffect(0x4e) # Soundeffect
			plant.say(1061858, '', '', False, 0x3b2, player.socket) # You soften the dirt with water.			

	# Potion
	elif item.hasscript('potions'):
		potiontype = potions.utilities.getPotionType(item)
		if applyPotion(player, plant, potiontype):			
			potions.utilities.consumePotion(player, item)
			player.soundeffect(0x240)

	# Potion Keg
	elif potionkeg.isPotionkeg(item):
		# Empty potion kegs won't work
		if not item.gettag('kegfill'):
			plant.say(1053069, '', '', False, 0x3b2, player.socket) # You can't use that on a plant!
		else:
			potiontype = potions.utilities.getPotionType(item)
			if applyPotion(player, plant, potiontype):
				item.settag('kegfill', item.gettag('kegfill') - 1)
				item.resendtooltip()
				player.soundeffect(0x240)

	# Something Else
	else:
		plant.say(1053069, '', '', False, 0x3b2, player.socket) # You can't use that on a plant!	
示例#6
0
def addPotion(player, plant, potiontypes):
    # Try to find an item to pour into the plant
    potion = None
    backpack = player.getbackpack()
    for item in backpack.content:
        if item.hasscript('potions'):
            potiontype = potions.utilities.getPotionType(item)
            if potiontype in potiontypes:
                potion = item
                break
        elif potionkeg.isPotionkeg(item) and item.gettag('kegfill'):
            potiontype = potions.utilities.getPotionType(item)
            if potiontype in potiontypes:
                potion = item
                break

    if potion:
        plants.plant.pour(player, plant, potion)
    else:
        # If we CAN apply a potion of the type, show a target
        if plants.plant.applyPotion(player, plant, potiontypes[0], True):
            player.socket.clilocmessage(
                1061884
            )  # You don't have any strong potions of that type in your pack.
            player.socket.clilocmessage(
                1060808, "#%u" % plants.plant.getStatusCliloc(plant)
            )  # Target the container you wish to use to water the ~1_val~.
            player.socket.attachtarget('plants.plant.pour_target',
                                       [plant.serial])

        # otherwise just print a message
        else:
            plant.say(
                1053065, '', '', False, 0x3b2, player.socket
            )  # The plant is already soaked with this type of potion!

    send(player, plant)  # Resend the main gump
def potionregion( cserial, iserial, bonus=0 ):
	char = wolfpack.findchar( cserial )
	item = wolfpack.finditem( iserial )
	if not item or not char:
		return False
	ppos = item.pos
	# Defaults
	outradius = 0
	potiontype = 11
	kegfill = 0
	iskeg = False

	potiontype = getPotionType( item )

	if not potiontype in [ 11, 12, 13 ]:
		potiontype = 11

	if potiontype == 11:
		outradius = 1
	elif potiontype == 12:
		outradius = 2
	elif potiontype == 13:
		outradius = randint( 2, 3 )
	else:
		outradius = 1

	# Potion Keg Radius Override!
	if isPotionkeg( item ):
		kegfill = int( item.gettag( 'kegfill' ) )
		if potiontype in [11, 12, 13] and kegfill >= 1:
			if kegfill == 100:
				outradius = 13
			elif kegfill >= 90:
				outradius = 12
			elif kegfill >= 80:
				outradius = 11
			elif kegfill >= 70:
				outradius = 10
			elif kegfill >= 60:
				outradius = 9
			elif kegfill >= 50:
				outradius = 8
			elif kegfill >= 40:
				outradius = 7
			elif kegfill >= 30:
				outradius = 6
			else:
				outradius = 5

	outradius = max( 1, outradius )

	# Potion is thrown on the ground
	if not item.container:
		x1 = min( int( ppos.x - outradius ), int( ppos.x + outradius ) )
		x2 = max( int( ppos.x - outradius ), int( ppos.x + outradius ) )
		y1 = min( int( ppos.y - outradius ), int( ppos.y + outradius ) )
		y2 = max( int( ppos.y - outradius ), int( ppos.y + outradius ) )
		# Character Bombing
		damageregion = wolfpack.charregion( x1, y1, x2, y2, ppos.map )
		target = damageregion.first
		while target:
			if not target.ischar:
				target = damageregion.next
			if checkLoS( target, item, outradius ):
				potiondamage( cserial, target, iserial, bonus, potiontype )
				target = damageregion.next
			else:
				target = damageregion.next

		# Chain Reaction Bombing
		chainregion = wolfpack.itemregion( x1, y1, x2, y2, ppos.map )
		chainbomb = chainregion.first
		# Scan the region, build a list of explosives
		while chainbomb:
			chainpotiontimer( cserial, iserial, chainbomb.serial, outradius )
			chainbomb = chainregion.next
		return
	# Potion is in a container
	else:
		x1 = min( int(char.pos.x - outradius), int(char.pos.x + outradius) )
		x2 = max( int(char.pos.x - outradius), int(char.pos.x + outradius) )
		y1 = min( int(char.pos.y - outradius), int(char.pos.y + outradius) )
		y2 = max( int(char.pos.y - outradius), int(char.pos.y + outradius) )
		# Area Bombing
		damageregion = wolfpack.charregion( x1, y1, x2, y2, char.pos.map )
		target = damageregion.first
		while target:
			if not target.ischar:
				target = damageregion.next
			if checkLoS( char, target, outradius ):
				potiondamage( cserial, target, iserial, bonus, potiontype )
				target = damageregion.next
			else:
				target = damageregion.next

		potion_chainlist = []
		# Chain Reaction Bombing
		chainregion = wolfpack.itemregion( x1, y1, x2, y2, char.pos.map )
		chainbomb = chainregion.first
		# Scan the region, build a list of explosives
		while chainbomb:
			chainpotiontimer( cserial, iserial, chainbomb.serial, outradius )
			chainbomb = chainregion.next
		return True
示例#8
0
def potionregion( cserial, iserial, bonus=0 ):
	char = wolfpack.findchar( cserial )
	item = wolfpack.finditem( iserial )
	if not item or not char:
		return False
	ppos = item.pos
	# Defaults
	outradius = 0
	potiontype = 11
	kegfill = 0
	iskeg = False

	potiontype = getPotionType( item )

	if not potiontype in [ 11, 12, 13 ]:
		potiontype = 11

	if potiontype == 11:
		outradius = 1
	elif potiontype == 12:
		outradius = 2
	elif potiontype == 13:
		outradius = randint( 2, 3 )
	else:
		outradius = 1

	# Potion Keg Radius Override!
	if isPotionkeg( item ):
		kegfill = int( item.gettag( 'kegfill' ) )
		if potiontype in [11, 12, 13] and kegfill >= 1:
			if kegfill == 100:
				outradius = 13
			elif kegfill >= 90:
				outradius = 12
			elif kegfill >= 80:
				outradius = 11
			elif kegfill >= 70:
				outradius = 10
			elif kegfill >= 60:
				outradius = 9
			elif kegfill >= 50:
				outradius = 8
			elif kegfill >= 40:
				outradius = 7
			elif kegfill >= 30:
				outradius = 6
			else:
				outradius = 5

	outradius = max( 1, outradius )

	# Potion is thrown on the ground
	if not item.container:
		x1 = min( int( ppos.x - outradius ), int( ppos.x + outradius ) )
		x2 = max( int( ppos.x - outradius ), int( ppos.x + outradius ) )
		y1 = min( int( ppos.y - outradius ), int( ppos.y + outradius ) )
		y2 = max( int( ppos.y - outradius ), int( ppos.y + outradius ) )
		# Character Bombing
		damageregion = wolfpack.charregion( x1, y1, x2, y2, ppos.map )
		target = damageregion.first
		while target:
			if not target.ischar:
				target = damageregion.next
			if checkLoS( target, item, outradius ):
				potiondamage( cserial, target, iserial, bonus, potiontype )
				target = damageregion.next
			else:
				target = damageregion.next

		# Chain Reaction Bombing
		chainregion = wolfpack.itemregion( x1, y1, x2, y2, ppos.map )
		chainbomb = chainregion.first
		# Scan the region, build a list of explosives
		while chainbomb:
			chainpotiontimer( cserial, iserial, chainbomb.serial, outradius )
			chainbomb = chainregion.next
		return
	# Potion is in a container
	else:
		x1 = min( int(char.pos.x - outradius), int(char.pos.x + outradius) )
		x2 = max( int(char.pos.x - outradius), int(char.pos.x + outradius) )
		y1 = min( int(char.pos.y - outradius), int(char.pos.y + outradius) )
		y2 = max( int(char.pos.y - outradius), int(char.pos.y + outradius) )
		# Area Bombing
		damageregion = wolfpack.charregion( x1, y1, x2, y2, char.pos.map )
		target = damageregion.first
		while target:
			if not target.ischar:
				target = damageregion.next
			if checkLoS( char, target, outradius ):
				potiondamage( cserial, target, iserial, bonus, potiontype )
				target = damageregion.next
			else:
				target = damageregion.next

		potion_chainlist = []
		# Chain Reaction Bombing
		chainregion = wolfpack.itemregion( x1, y1, x2, y2, char.pos.map )
		chainbomb = chainregion.first
		# Scan the region, build a list of explosives
		while chainbomb:
			chainpotiontimer( cserial, iserial, chainbomb.serial, outradius )
			chainbomb = chainregion.next
		return True