Exemple #1
0
def fireweapon(attacker, defender, weapon):
	ammo = properties.fromitem(weapon, AMMUNITION)

	# Only consume ammo if this weapon requires it
	if len(ammo) != 0:
		if not consumeresources(attacker.getbackpack(), ammo, 1):
			if attacker.socket:
				attacker.socket.sysmessage('You are out of ammo.')
			if attacker.npc:
				tobackpack(weapon, attacker)
			return False

		if random.random() >= 0.50:
			if defender.player:
				item = wolfpack.additem(ammo)
				if not tobackpack(item, defender):
					item.update()
			else:
				# Search for items at the same position
				items = wolfpack.items(defender.pos.x, defender.pos.y, defender.pos.map)
				handled = 0

				for item in items:
					if item.baseid == ammo:
						item.amount += 1
						item.update()
						handled = 1
						break

				if not handled:
					item = wolfpack.additem(ammo)
					item.moveto(defender.pos)
					item.update()

	projectile = properties.fromitem(weapon, PROJECTILE)

	# Fire a projectile if applicable.
	if projectile:
		hue = properties.fromitem(weapon, PROJECTILEHUE)
		attacker.movingeffect(projectile, defender, 0, 0, 14, hue)

	return True
Exemple #2
0
def fireweapon(attacker, defender, weapon):
    ammo = properties.fromitem(weapon, AMMUNITION)

    # Only consume ammo if this weapon requires it
    if len(ammo) != 0:
        if not consumeresources(attacker.getbackpack(), ammo, 1):
            if attacker.socket:
                attacker.socket.sysmessage(tr('You are out of ammo.'))
            if attacker.npc:
                tobackpack(weapon, attacker)
            return False

        # The ammo is created and packed into the defenders backpack/put on the ground
        createammo(defender, ammo)

    projectile = properties.fromitem(weapon, PROJECTILE)

    # Fire a projectile if applicable.
    if projectile:
        hue = properties.fromitem(weapon, PROJECTILEHUE)
        attacker.movingeffect(projectile, defender, 0, 0, 14, hue)

    return True
Exemple #3
0
def fireweapon(attacker, defender, weapon):
	ammo = properties.fromitem(weapon, AMMUNITION)

	# Only consume ammo if this weapon requires it
	if len(ammo) != 0:
		if not consumeresources(attacker.getbackpack(), ammo, 1):
			if attacker.socket:
				attacker.socket.sysmessage(tr('You are out of ammo.'))
			if attacker.npc:
				tobackpack(weapon, attacker)
			return False

		# The ammo is created and packed into the defenders backpack/put on the ground
		createammo(defender, ammo)

	projectile = properties.fromitem(weapon, PROJECTILE)

	# Fire a projectile if applicable.
	if projectile:
		hue = properties.fromitem(weapon, PROJECTILEHUE)
		attacker.movingeffect(projectile, defender, 0, 0, 14, hue)

	return True