Esempio n. 1
0
def loadSettings():
    global interval, htmltemplate, outputfile
    interval = settings.getnumber("HTML Status", "Interval in Seconds", 60,
                                  True) * 1000
    htmltemplate = settings.getstring("HTML Status", "HTML Template",
                                      "web/status_template.html", True)
    outputfile = settings.getstring("HTML Status", "Output Path",
                                    "web/status.html", True)
Esempio n. 2
0
def onServerStart():
	web.sessions.clear_sessions()

	# Get the remote admin port
	port = settings.getnumber('Network', 'Remoteadmin Port', 2594, True)

	global thread
	thread = WebserverThread( port )
	thread.start()
Esempio n. 3
0
def onLoad():
	# Not on ServerStart
	if not wolfpack.isstarting():
		web.sessions.clear_sessions()
		
		# Get the remote admin port
		port = settings.getnumber('Network', 'Remoteadmin Port', 2594, True)
		
		# Start the Thread
		global thread
		thread = WebserverThread( port )
		thread.start()
Esempio n. 4
0
def onSkillGain(char, skill, lower, higher, success):
	# See if we can gain at all
	# GMs don't gain skills
	if char.dead or char.gm or char.polymorph:
		return

	if not SKILLS.has_key(skill):
		char.log(LOG_ERROR, "Is using an unidentified skill: %u\n" % skill)
		return

	info = SKILLS[skill]
	skills = char.skill
	value = skills[skill] / 10.0 # Convert into float
	lower /= 10.0
	higher /= 10.0

	# NPCs only learn by using skills
	# they already have
	if char.npc and value <= 0.0:
		return

	# No gain for effortless or futile attempts
	if value >= higher:
		return

	chance = (value - lower) / (higher - lower)
	cap = char.skillcap[skill] / 10.0

	# Skills capped at zero are disabled for this character
	if cap == 0:
		return

	totalskills = 0.0
	for i in range(0, ALLSKILLS):
		# See if there is a modifier for the skill
		tagname = 'skillbonus_%u' % i
		totalskills += skills[i] / 10.0

		if char.hastag(tagname):
			try:
				tagvalue = int(char.gettag(tagname))
				totalskills -= tagvalue / 10.0
			except:
				pass

	# Calculate the GainChance
	# (RunUO has a nice approach. Doing it similar)
	totalcap = settings.getnumber("General", "SkillCap", 700)
	gainchance = (totalcap - totalskills) / totalcap # How near are we to our global skill cap
	gainchance += (cap - value) / cap # How near are we to our skill cap

	# Use the difficulty to influence the skill gain
	if success:
		gainchance += 0.5 - chance * 0.5
	else:
		gainchance += 0.2 - chance * 0.2

	gainchance /= 3.0 # The average of the three values

	# Introduce a new "Gain Factor"
	# There is also a 1% minimum chance for gain
	gainchance = gainchance * info[SKILL_GAINFACTOR]

	# Multiply with another gainfactor
	gainchance = gainchance * GLOBAL_FACTOR

	# Tamed creatures get a * 2 bonus for their gain.
	if char.npc and char.tamed:
		gainchance *= 2

	# Skills below 10% always gain, otherwise take the gainchance into
	# account.
	if gainchance >= random() or value < 10.0:
		gainskill(char, skill, totalskills, totalcap)

	lock = char.skilllock[skill] # Lock value for the skill

	# It's not important that we actually gained the skill
	# in order to gain stats by using it.
	if lock == 0:
		strchance = info[SKILL_STRCHANCE]
		dexchance = info[SKILL_DEXCHANCE]
		intchance = info[SKILL_INTCHANCE]
		realstr = char.strength - char.strength2
		realdex = char.dexterity - char.dexterity2
		realint = char.intelligence - char.intelligence2

		if (char.npc or char.strengthlock != 0) or realstr >= char.strengthcap:
			strchance = 0.0
		else:
			strchance /= 33.3

		if (char.npc or char.dexteritylock != 0) or realdex >= char.dexteritycap:
			dexchance = 0.0
		else:
			dexchance /= 33.3

		if (char.npc or char.intelligencelock != 0) or realint >= char.intelligencecap:
			intchance = 0.0
		else:
			intchance /= 33.3

		# Gainchances for stats
		#if skill != FOCUS:
		#	char.log(LOG_TRACE, "Gainchances. Skill %s. Str: %f Dex: %f Int: %f\n" % (SKILLNAMES[skill], strchance, dexchance, intchance))

		# Roll three times
		if strchance > random():
			gainstat(char, 0)
		elif dexchance > random():
			gainstat(char, 1)
		elif intchance > random():
			gainstat(char, 2)
Esempio n. 5
0
def loadSettings():
	global interval, htmltemplate, outputfile
	interval = settings.getnumber("HTML Status", "Interval in Seconds", 60, True) * 1000
	htmltemplate = settings.getstring("HTML Status", "HTML Template", "web/status_template.html", True)
	outputfile = settings.getstring("HTML Status", "Output Path", "web/status.html", True)
Esempio n. 6
0
def onSkillGain(char, skill, lower, higher, success):
  # See if we can gain at all
  # GMs don't gain skills
  if char.dead or char.gm or char.polymorph:
    return

  if not SKILLS.has_key(skill):
    char.log(LOG_ERROR, "Is using an unidentified skill: %u\n" % skill)
    return

  info = SKILLS[skill]
  skills = char.skill
  value = skills[skill] / 10.0 # Convert into float
  lower /= 10.0
  higher /= 10.0

  # NPCs only learn by using skills
  # they already have
  if char.npc and value <= 0.0:
    return

  # No gain for effortless or futile attempts
  if value < lower or value >= higher:
    return

  chance = (value - lower) / (higher - lower)
  cap = char.skillcap[skill] / 10.0

  # Skills capped at zero are disabled for this character
  if cap == 0:
    return

  totalskills = 0.0
  for i in range(0, ALLSKILLS):
    totalskills += skills[i] / 10.0

  # Calculate the GainChance
  # (RunUO has a nice approach. Doing it similar)
  totalcap = settings.getnumber("General", "SkillCap", 700)
  gainchance = (totalcap - totalskills) / totalcap # How near are we to our global skill cap
  gainchance += (cap - value) / cap # How near are we to our skill cap

  # Use the difficulty to influence the skill gain
  if success:
    gainchance += 0.5 - chance * 0.5
  else:
    gainchance += 0.2 - chance * 0.2

  gainchance /= 3.0 # The average of the three values

  # Introduce a new "Gain Factor"
  # There is also a 1% minimum chance for gain
  gainchance = max(0.01, gainchance * info[SKILL_GAINFACTOR])

  # Tamed creatures get a * 2 bonus for their gain.
  if char.npc and char.tamed:
    gainchance *= 2

  # Skills below 10% always gain, otherwise take the gainchance into
  # account.
  if gainchance >= random() or value < 10.0:
    gainskill(char, skill, totalskills, totalcap)
Esempio n. 7
0
def docarve( char, item, target ):
	# Corpse => Carve
	# Wood => Kindling/Logs
	model = 0

	if target.item:
		if carve_item( char, item, target ):
			return
		else:
			model = target.item.id

	# This is for sheering only
	elif target.char and target.char.npc:
		if target.char.baseid == 'sheep_unsheered':
			target.char.id = 223
			target.char.baseid = 'sheep_sheered'
			target.char.update()

			# Create Wool
			wool = wolfpack.additem("df8")
			wool.amount = 2

			if not utilities.tobackpack(wool, char):
				wool.update()

			# Resend weight
			char.socket.resendstatus()

			char.socket.clilocmessage( 500452 ) # You place the gathered wool into your backpack.

			# Let the wool regrow (minutes)
			delay = settings.getnumber('Game Speed', 'Regrow Wool Minutes', 180, 1)
			delay *= 60000 # Miliseconds per Minute
			target.char.dispel(None, 1, "regrow_wool", [])
			target.char.addtimer(delay, regrow_wool, [], 1, 0, "regrow_wool")
			return
		elif target.char.baseid == 'sheep' or target.char.baseid == 'sheep_sheered':
			char.socket.clilocmessage( 500449 ) # This sheep is not yet ready to be shorn.
			return
		else:
			char.socket.clilocmessage( 500450 ) # You can only skin dead creatures.
			return
	else:
		model = target.model

	if target.model == 0:
		map = wolfpack.map( target.pos.x, target.pos.y, target.pos.map )
		treeid = map['id']
	elif target.model != 0:
		treeid = target.model

	if utilities.istree(treeid):
		# Axes/Polearms get Logs, Swords get kindling.
		# Also allows a mace's war axe to be use. 0x13af and 0x13b0
		if item.type == 1002 or item.id == 0x13af or item.id == 0x13b0:
			if not item or not item.container == char:
				char.message( 502641, "" ) # You must equip this item to use it.
				return
			else:
				skills.lumberjacking.response( [ target, item, char ] )
		# Swords and Fencing Weapons: Get kindling
		elif item.type == 1001 or item.type == 1005:
			skills.lumberjacking.hack_kindling( char, target.pos )
	else:
		char.socket.clilocmessage( 500494, "", GRAY ) # You can't use a bladed item on that.
		return False
Esempio n. 8
0
def response(char, args, target):
    item = wolfpack.finditem(args[0])
    if not item:
        return

    if target.char and not char.canreach(target.char, 5):
        char.socket.clilocmessage(500312)
        return

    elif not target.item and not char.canreach(target.pos, 5):
        char.socket.clilocmessage(500312)
        return

        # Corpse => Carve
        # Wood => Kindling/Logs
    model = 0

    if target.item:
        if target.item.id == 0x2006 and target.item.corpse:
            if not char.canreach(target.item, 5):
                char.socket.clilocmessage(500312)
                return

            carve_corpse(char, target.item)
            return

            # For cutting fish
        elif target.item.id in fish:
            if target.item.getoutmostchar() != char:
                char.socket.clilocmessage(500312)
                return

            cut_fish(char, target.item)
            return

        else:
            model = target.item.id

            # This is for sheering only
    elif target.char and target.char.npc:
        if target.char.baseid == "sheep_unsheered":
            target.char.id = 223
            target.char.baseid = "sheep_sheered"
            target.char.update()

            # Create Wool
            wool = wolfpack.additem("df8")
            wool.amount = 2

            if not utilities.tobackpack(wool, char):
                wool.update()

            char.socket.clilocmessage(0x7A2E4)  # You place the gathered wool into your backpack.

            # Let the wool regrow (minutes)
            delay = settings.getnumber("Game Speed", "Regrow Wool Minutes", 180, 1)
            delay *= 60000  # Miliseconds per Minute
            target.char.dispel(None, 1, "regrow_wool", [])
            target.char.addtimer(delay, "blades.regrow_wool", [], 1, 0, "regrow_wool")
            return
        elif target.char.id == "sheep_sheered":
            char.socket.clilocmessage(0x7A2E1)  # This sheep is not yet ready to be shorn.
            return
        else:
            char.socket.clilocmessage(0x7A2E2)  # You can only skin dead creatures.
            return
    else:
        model = target.model

    if target.model == 0:
        map = wolfpack.map(target.pos.x, target.pos.y, target.pos.map)
        treeid = map["id"]
    elif target.model != 0:
        treeid = target.model

    if utilities.istree(treeid):
        # Axes/Polearms get Logs, Swords get kindling.
        # Also allows a mace's war axe to be use. 0x13af and 0x13b0
        if item.type == 1002 or item.id == 0x13AF or item.id == 0x13B0:
            if not item or not item.container == char:
                char.message("You must equip this item to use it on this target!")
                return
            else:
                skills.lumberjacking.response([target, item, char])
                # Swords and Fencing Weapons: Get kindling
        elif item.type == 1001 or item.type == 1005:
            skills.lumberjacking.hack_kindling(char, target.pos)
    else:
        # You can't use a bladed item on that.
        char.socket.clilocmessage(500494, "", GRAY)
        return False
Esempio n. 9
0
def onSkillGain(char, skill, lower, higher, success):
    # See if we can gain at all
    # GMs don't gain skills
    if char.dead or char.gm or char.polymorph:
        return

    if not skill in SKILLS:
        char.log(LOG_ERROR, "Is using an unidentified skill: %u\n" % skill)
        return

    info = SKILLS[skill]
    skills = char.skill
    value = skills[skill] / 10.0  # Convert into float
    lower /= 10.0
    higher /= 10.0

    # NPCs only learn by using skills
    # they already have
    if char.npc and value <= 0.0:
        return

    # No gain for effortless or futile attempts
    if value >= higher:
        return

    chance = (value - lower) / (higher - lower)
    cap = char.skillcap[skill] / 10.0

    # Skills capped at zero are disabled for this character
    if cap == 0:
        return

    totalskills = 0.0
    for i in range(0, ALLSKILLS):
        # See if there is a modifier for the skill
        tagname = 'skillbonus_%u' % i
        totalskills += skills[i] / 10.0

        if char.hastag(tagname):
            try:
                tagvalue = int(char.gettag(tagname))
                totalskills -= tagvalue / 10.0
            except:
                pass

    # Calculate the GainChance
    # (RunUO has a nice approach. Doing it similar)
    totalcap = settings.getnumber("General", "SkillCap", 700)
    gainchance = (totalcap - totalskills
                  ) / totalcap  # How near are we to our global skill cap
    gainchance += (cap - value) / cap  # How near are we to our skill cap

    # Use the difficulty to influence the skill gain
    if success:
        gainchance += 0.5 - chance * 0.5
    else:
        gainchance += 0.2 - chance * 0.2

    gainchance /= 3.0  # The average of the three values

    # Introduce a new "Gain Factor"
    # There is also a 1% minimum chance for gain
    gainchance = gainchance * info[SKILL_GAINFACTOR]

    # Multiply with another gainfactor
    gainchance = gainchance * GLOBAL_FACTOR

    # Tamed creatures get a * 2 bonus for their gain.
    if char.npc and char.tamed:
        gainchance *= 2

    # Skills below 10% always gain, otherwise take the gainchance into
    # account.
    if gainchance >= random() or value < 10.0:
        gainskill(char, skill, totalskills, totalcap)

    lock = char.skilllock[skill]  # Lock value for the skill

    # It's not important that we actually gained the skill
    # in order to gain stats by using it.
    if lock == 0:
        strchance = info[SKILL_STRCHANCE]
        dexchance = info[SKILL_DEXCHANCE]
        intchance = info[SKILL_INTCHANCE]
        realstr = char.strength - char.strength2
        realdex = char.dexterity - char.dexterity2
        realint = char.intelligence - char.intelligence2

        if (char.npc or char.strengthlock != 0) or realstr >= char.strengthcap:
            strchance = 0.0
        else:
            strchance /= 33.3

        if (char.npc
                or char.dexteritylock != 0) or realdex >= char.dexteritycap:
            dexchance = 0.0
        else:
            dexchance /= 33.3

        if (char.npc or
                char.intelligencelock != 0) or realint >= char.intelligencecap:
            intchance = 0.0
        else:
            intchance /= 33.3

        # Gainchances for stats
        #if skill != FOCUS:
        #	char.log(LOG_TRACE, "Gainchances. Skill %s. Str: %f Dex: %f Int: %f\n" % (SKILLNAMES[skill], strchance, dexchance, intchance))

        # Roll three times
        if strchance > random():
            gainstat(char, 0)
        elif dexchance > random():
            gainstat(char, 1)
        elif intchance > random():
            gainstat(char, 2)