View Single Post
  #2  
Old 07-03-2013, 11:52 PM
Secrets's Avatar
Secrets
Demi-God
 
Join Date: May 2007
Location: b
Posts: 1,449
Default

Quote:
Originally Posted by KLS View Post
Just to add to the example you can take it and do something like:

Code:
function NPC:Scale(level, zoneid, instanceid, scalerate, loottableid)
	--Set up static constants, these are close to PEQ values:
	local hpval = ((level * (11 + level)) * scalerate) / 100
	local manaval = ((level * (11 + level))  * scalerate) / 100
	local endurval = ((level * (11 + level))  * scalerate) / 100
	local min_dmg = (((level + 2) + level)   * scalerate) / 100
	local max_dmg = (((level * 2) + level)   * scalerate) / 100
	local ac = ((28 + (4 * level))   * scalerate) / 100
	local hp_regen_rate = (((level / 5) + 1) * scalerate) / 100
	local mana_regen_rate = (((level / 5) + 1)   * scalerate) / 100
	local rawstats 	= ((75 + (level * 2)) * scalerate) / 100

	--[[ 
	Lua supports nice looking comments too, so why not tell people we are starting the actual scaling here?
	Maybe include instance version at some point to the equation? :)
	--]]
	
	self:AddLootTable(loottableid)
	self:ModifyNPCStat("str", tostring(rawstats))
	self:ModifyNPCStat("sta", tostring(rawstats))
	self:ModifyNPCStat("agi", tostring(rawstats))
	self:ModifyNPCStat("dex", tostring(rawstats))
	self:ModifyNPCStat("wis", tostring(rawstats))
	self:ModifyNPCStat("int", tostring(rawstats))
	self:ModifyNPCStat("cha", tostring(rawstats))
	self:ModifyNPCStat("ac", tostring(ac))
	self:ModifyNPCStat("max_hp", tostring(hpval))
	self:ModifyNPCStat("mana", tostring(manaval))
	self:ModifyNPCStat("min_hit", tostring(min_dmg))
	self:ModifyNPCStat("max_hit", tostring(max_dmg))
	self:ModifyNPCStat("hp_regen", tostring(hp_regen_rate))
	self:ModifyNPCStat("mana_regen", tostring(hp_regen_rate))
	self:ModifyNPCStat("level", tostring(level))
	self:ModifyNPCStat("healscale", tostring(healscale))
	self:ModifyNPCStat("spellscale", tostring(spellscale))
	self:Heal()
end
and in your global/script_init.lua add
require("lua_scale")

Then you could literally do

Code:
function event_say(e)
	e.self:Say("Scaleme!")
	e.self:Scale(e.message, eq.get_zone_id(), eq.get_zone_instance_id(), 100, 1)
end
Inheritance issues can sometimes make it a bit tricky though as these wont be in the metatable lookup that deals with inheritance.
Interesting addition, KLS.

Hopefully this will cut down the need for so many functions that we generally export to perl - except they'll be faster.
Reply With Quote