創作內容

1 GP

楓之谷2--Alpha測試:計算公式一覽(程式碼)

作者:佛瑞長蘇│2014-09-21 12:13:04│巴幣:2│人氣:376


取自於SP,稍微看一下,不懂可以查查單字可以看出一些訊息,譬如:職業種類、武器種類
、一些傷害計算方法、能力值計算方法之類的....不過我想這些數值都還會再更動,所以先看看吧!希望有人可以整理出比較好懂得計算公式....

上面網址進入往下拉有個"Interesting Excel Files",可以下載下來看看,裡面有怪物、菁英、地城BOSS的經驗值,還有寶箱訊息(這我沒看),其他還有一些解出來的圖片....

-----------------------------------------------------------------------------------------------------------------------
math.randomseed(os.time())

-- *********************************************************************************************************************************************************************
-- 대미지 등급 정의
DG_Normal= 0
DG_Critical= 1
DG_Miss= 2
DG_Block= 3

-- *********************************************************************************************************************************************************************
-- 직업 정의
JC_Newbie= 1
JC_Knight= 10
JC_Berserker= 20
JC_Wizard= 30
JC_Priest= 40
JC_Ranger= 50
JC_HeavyGunner= 60
JC_Thief= 70
JC_Assassin= 80
JC_GM= 999

-- *********************************************************************************************************************************************************************
-- 무기
ISC_BLUNT= 30
ISC_DAGGER= 31
ISC_LONGSWORD= 32
ISC_SCEPTRE= 33
ISC_JAVELIN= 34
ISC_SPELLBOOK= 40
ISC_SHIELD= 41
ISC_LARGESWORD= 50
ISC_BOW= 51
ISC_STAFF= 52
ISC_HEAVYGUN= 53

-- *********************************************************************************************************************************************************************
-- 주/부 스탯
Major= 0
Minor= 1

-- *********************************************************************************************************************************************************************
-- 크리티컬 주스탯
CRITICAL = {}
CRITICAL[Major] = {}
CRITICAL[Major][JC_Newbie]= 0.7
CRITICAL[Major][JC_Knight]= 0.75
CRITICAL[Major][JC_Berserker]= 0.08
CRITICAL[Major][JC_Wizard]= 0.08
CRITICAL[Major][JC_Priest]= 0.9
CRITICAL[Major][JC_Ranger]= 0.5
CRITICAL[Major][JC_HeavyGunner]= 0.08
CRITICAL[Major][JC_Thief]= 0.2
CRITICAL[Major][JC_Assassin]= 0.2
CRITICAL[Major][JC_GM]= 0.7

-- *********************************************************************************************************************************************************************
-- 물리 주스탯
PAP = {}
PAP[Major] = {}
PAP[Major][JC_Newbie]= 0.09
PAP[Major][JC_Knight]= 0.09
PAP[Major][JC_Berserker]= 0.09
PAP[Major][JC_Wizard]= 0.06
PAP[Major][JC_Priest]= 0.06
PAP[Major][JC_Ranger]= 0.09
PAP[Major][JC_HeavyGunner]= 0.09
PAP[Major][JC_Thief]= 0.09
PAP[Major][JC_Assassin]= 0.09
PAP[Major][JC_GM]= 0.09

-- *********************************************************************************************************************************************************************
-- 물리 보조스탯
PAP[Minor] = {}
PAP[Minor][JC_Newbie]= 0.025
PAP[Minor][JC_Knight]= 0.025
PAP[Minor][JC_Berserker]= 0.025
PAP[Minor][JC_Wizard]= 0.025
PAP[Minor][JC_Priest]= 0.025
PAP[Minor][JC_Ranger]= 0.025
PAP[Minor][JC_HeavyGunner]= 0.025
PAP[Minor][JC_Thief]= 0.025
PAP[Minor][JC_Assassin]= 0.025
PAP[Minor][JC_GM]= 0.025

-- *********************************************************************************************************************************************************************
-- 마법 주스탯
MAP = {}
MAP[Major] = {}
MAP[Major][JC_Newbie]= 0.05
MAP[Major][JC_Knight]= 0.05
MAP[Major][JC_Berserker]= 0.05
MAP[Major][JC_Wizard]= 0.063
MAP[Major][JC_Priest]= 0.063
MAP[Major][JC_Ranger]= 0.05
MAP[Major][JC_HeavyGunner]= 0.05
MAP[Major][JC_Thief]= 0.05
MAP[Major][JC_Assassin]= 0.05
MAP[Major][JC_GM]= 0.05

-- *********************************************************************************************************************************************************************
-- 무기 공격력 보정
WEAPON = {}
WEAPON[Major] = {}
WEAPON[Major][ISC_BLUNT]= 1.3
WEAPON[Major][ISC_DAGGER]= 1.3
WEAPON[Major][ISC_LONGSWORD]= 1.3
WEAPON[Major][ISC_SCEPTRE]= 1.3
WEAPON[Major][ISC_JAVELIN]= 1.3
WEAPON[Major][ISC_SPELLBOOK]= 1.3
WEAPON[Major][ISC_SHIELD]= 1.3
WEAPON[Major][ISC_LARGESWORD]= 1.3
WEAPON[Major][ISC_BOW]= 1.3
WEAPON[Major][ISC_STAFF]= 1.3
WEAPON[Major][ISC_HEAVYGUN]= 1.3

-- *********************************************************************************************************************************************************************
-- 추가 보정
--CORRECT_WEAPON= 0.4
CORRECT_STAT= 7
CORRECT_CRITICAL= 0.01
CORRECT_phyRes= 1.1
CORRECT_magicRes= 1.1

-- *********************************************************************************************************************************************************************
-- 물리 대미지 저항 주스탯 & 부스탯 보정.
phyRes = {}
phyRes[Major] = {}
phyRes[Major][JC_Newbie]= 0.01
phyRes[Major][JC_Knight]= 0.01
phyRes[Major][JC_Berserker]= 0.01
phyRes[Major][JC_Wizard]= 0.04
phyRes[Major][JC_Priest]= 0.04
phyRes[Major][JC_Ranger]= 0.015
phyRes[Major][JC_HeavyGunner]= 0.015
phyRes[Major][JC_Thief]= 0.015
phyRes[Major][JC_Assassin]= 0.015
phyRes[Major][JC_GM]= 0.01

phyRes[Minor] = {}
phyRes[Minor][JC_Newbie]= 0.015
phyRes[Minor][JC_Knight]= 0.015
phyRes[Minor][JC_Berserker]= 0.015
phyRes[Minor][JC_Wizard]= 0.04
phyRes[Minor][JC_Priest]= 0.04
phyRes[Minor][JC_Ranger]= 0.005
phyRes[Minor][JC_HeavyGunner]= 0.01
phyRes[Minor][JC_Thief]= 0.015
phyRes[Minor][JC_Assassin]= 0.015
phyRes[Minor][JC_GM]= 0.015

-- *********************************************************************************************************************************************************************
-- 마법 대미지 저항 주스탯.
magicRes = {}
magicRes[Major] = {}
magicRes[Major][JC_Newbie]= 0.05
magicRes[Major][JC_Knight]= 0.05
magicRes[Major][JC_Berserker]= 0.05
magicRes[Major][JC_Wizard]= 0.01
magicRes[Major][JC_Priest]= 0.01
magicRes[Major][JC_Ranger]= 0.05
magicRes[Major][JC_HeavyGunner]= 0.05
magicRes[Major][JC_Thief]= 0.05
magicRes[Major][JC_Assassin]= 0.05
magicRes[Major][JC_GM]= 0.05

-- *********************************************************************************************************************************************************************
-- sp interval, value
-- interval
sp_interval = {}
sp_interval[JC_Newbie]= 1000
sp_interval[JC_Knight]= 1000
sp_interval[JC_Berserker]= 1000
sp_interval[JC_Wizard]= 1000
sp_interval[JC_Priest]= 1000
sp_interval[JC_Ranger]= 1000
sp_interval[JC_HeavyGunner]= 1000
sp_interval[JC_Thief]= 1000
sp_interval[JC_Assassin]= 1000
sp_interval[JC_GM]= 1000

-- value
sp_value = {}
sp_value[JC_Newbie]= 1
sp_value[JC_Knight]= 1
sp_value[JC_Berserker]= 1
sp_value[JC_Wizard]= 1
sp_value[JC_Priest]= 1
sp_value[JC_Ranger]= 1
sp_value[JC_HeavyGunner]= 1
sp_value[JC_Thief]= 1
sp_value[JC_Assassin]= 1
sp_value[JC_GM]= 1

-- *********************************************************************************************************************************************************************
-- sp 재생력
function calc_sp_regen(jobcode, max_sp, amount, interval, elapsedTime, sit)
local rst_ssr = 0

if elapsedTime >= sp_interval[jobcode] then
if sit == 1 then
rst_ssr = sp_value[jobcode]
else
rst_ssr = sp_value[jobcode]
end
end

return rst_ssr
end

-- *********************************************************************************************************************************************************************
-- ep interval, value
-- interval
ep_interval = {}
ep_interval[JC_Newbie]= 500
ep_interval[JC_Knight]= 500
ep_interval[JC_Berserker]= 500
ep_interval[JC_Wizard]= 500
ep_interval[JC_Priest]= 500
ep_interval[JC_Ranger]= 500
ep_interval[JC_HeavyGunner]= 500
ep_interval[JC_Thief]= 500
ep_interval[JC_Assassin]= 500
ep_interval[JC_GM]= 500

-- value
ep_value = {}
ep_value[JC_Newbie]= 10
ep_value[JC_Knight]= 10
ep_value[JC_Berserker]= 10
ep_value[JC_Wizard]= 10
ep_value[JC_Priest]= 10
ep_value[JC_Ranger]= 10
ep_value[JC_HeavyGunner]= 10
ep_value[JC_Thief]= 10
ep_value[JC_Assassin]= 10
ep_value[JC_GM]= 10

-- *********************************************************************************************************************************************************************
-- ep 재생력
function calc_ep_regen(jobcode, max_ep, amount, interval, elapsedTime, sit)
local rst_ser = 0

if elapsedTime >= ep_interval[jobcode] then
if sit == 1 then
rst_ser = ep_value[jobcode]
else
rst_ser = ep_value[jobcode]
end
end

return rst_ser
end

-- *********************************************************************************************************************************************************************
-- 값 클리핑
function clip_value(x, min, max)
if x < min then x = min end
if x > max then x = max end
return x
end

-- *********************************************************************************************************************************************************************
-- 이동 속도율
--function calc_msiR(mspV)
--local rst_msiRate = (mspV / (mspV + 18)) * 1.3
--return clip_value(rst_msiRate, 0.031, 1.25)
--end

-- 이동 속도 스탯을 그대로 가져와서 연산하게 변경_140911_이정섭.
function calc_msiR(mspV)
--local rst_msiRate = (mspV / (mspV + 18)) * 1.3
local rst_msiRate = mspV / 100
return clip_value(rst_msiRate, 0.07, 1.65)
end


-- *********************************************************************************************************************************************************************
-- 도약률
function calc_jmiR(jmpV)
return math.max(jmpV / 100, 0)
end

-- *********************************************************************************************************************************************************************
-- 공격 속도율
function calc_asiR(aspV, seq_speed)
local rst_asiRate = (aspV / (aspV + 804)) * 0.5 + 1.0
return math.max(rst_asiRate * seq_speed, 0)
end

-- *********************************************************************************************************************************************************************
-- hp 재생력
function calc_hp_regen(jobcode, max_hp, amount, interval, elapsedTime, sit)
local rst_shr = 0

if elapsedTime >= interval then
if sit == 1 then
rst_shr = amount * 1.5
else
rst_shr = amount
end
end

return rst_shr
end


-- ************************************************************************************************************************************************
-- stat 가/감/승/제
function calc_stat_sum(base_statV, item_statV, item_statR, skill_statV, skill_statR)
local rst_sum = 0

rst_sum = (base_statV + item_statV + skill_statV) * (1 + item_statR + skill_statR)

return rst_sum
end

-- ************************************************************************************************************************************************
-- 완전 방어 판정.
function calc_abp(abp, finalAbpV, finalAbpR)
return abp
end

-- *********************************************************************************************************************************************************************
-- HP 회복 공식: 마법 공격력과 연산하여 회복량 산출.
function calc_recoveryHP(map, maxHP, rate)
return map * rate
end

-- ************************************************************************************************************************************************
-- npc크리티컬 확률
function calc_npc_cap(luk, cap, car)
local rst_cap = ((luk + cap) / car) * CORRECT_CRITICAL
return clip_value(rst_cap, 0, 0.5)
end

-- ************************************************************************************************************************************************
-- pc크리티컬 확률
function calc_pc_cap(jobcode, luk, cap, car, finalCapV, finalCapR)
local rst_cap = ((luk * CRITICAL[Major][jobcode] + cap) / car) * CORRECT_CRITICAL
return clip_value(rst_cap, 0, 0.5)
end

-- ************************************************************************************************************************************************
-- 물리 공격력
function calc_pap(jobcode, papV, papR, major, minor)
--local rst_pap = ((major * PAP[Major][jobcode]) + (minor * PAP[Minor][jobcode])) * CORRECT_STAT
--local rst_pap = ((((major * PAP[Major][jobcode]) + (minor * PAP[Minor][jobcode])) + papV) * math.max(0.1, 1 + papR)) * CORRECT_STAT
local rst_pap = ((((major * PAP[Major][jobcode]) + (minor * PAP[Minor][jobcode])) * CORRECT_STAT) + papV) * math.max(0.1, 1 + papR)
return math.max(1, rst_pap)
end

-- ************************************************************************************************************************************************
-- 마법 공격력(jobcode:직업코드, major:주스탯)
function calc_map(jobcode, mapV, mapR, major)
--local rst_map = (major * MAP[Major][jobcode]) * CORRECT_STAT
local rst_map = (((major * MAP[Major][jobcode]) * CORRECT_STAT) + mapV) * math.max(0.1, 1 + mapR)
return math.max(1, rst_map)
end

-- *********************************************************************************************************************************************************************
-- 물리 대미지 저항.
function calc_par(jobcode, phyResV, phyResR, major, minor)
--local rst_phyRes = math.min(0.2, ((((major * phyRes[Major][jobcode]) + (minor * phyRes[Minor][jobcode])) * CORRECT_phyRes) - phyResV) * math.max(1 / phyResR, 1))
--return clip_value(rst_phyRes, 20, 100)
local rst_phyRes = ((((major * phyRes[Major][jobcode]) + (minor * phyRes[Minor][jobcode])) * CORRECT_phyRes * 100) + phyResV) * math.max(0.1, 1 + phyResR)
return clip_value(rst_phyRes, 0, 8000)
end

-- *********************************************************************************************************************************************************************
-- 마법 대미지 저항.
function calc_mar(jobcode, magicResV, magicResR, major)
--local rst_magicRes = math.min(0.2, (((major * magicRes[Major][jobcode]) * CORRECT_phyRes) - magicResV) * math.max(1 / magicResR, 1))
--return clip_value(rst_magicRes, 20, 100)
local rst_magicRes = (((major * magicRes[Major][jobcode]) * CORRECT_magicRes * 100) + magicResV) * math.max(0.1, 1 + magicResR)
return clip_value(rst_magicRes, 0, 8000)
end

-- ************************************************************************************************************************************************
-- npc최종 공격력(tap:최종공격력, dv:대미지 밸류, dr:대미지 레이트)
function calc_npc_tap(tap, dv, dr)
local rst_tap = tap * dr
return rst_tap
end

-- ************************************************************************************************************************************************
--pc최종 공격력(wap:무기 공격력)
-- 기존 공식: ((math.max(wap, 1) * WEAPON[Major][ISC_BLUNT]) * CORRECT_WEAPON) * tap * (dr * (math.max(cost_sp, 1) * sp_weight))
function calc_pc_tap(wap, tap, dv, dr, cost_sp, cost_ep, sp_weight)
--local rst_tap = ((math.max(wap, 1) * WEAPON[Major][ISC_BLUNT])) * tap * (dr + (cost_sp * sp_weight) + (cost_ep * (sp_weight * 0.2)))
local rst_tap = ((math.max(wap, 1) * WEAPON[Major][ISC_BLUNT])) * tap * dr
return rst_tap
end

-- ************************************************************************************************************************************************
-- 대미지(cad:크리티컬 대미지, ndd:방어력, tar:[물리저항력(par) or 마법저항력(mar)])
-- 기존 공식 math.max(rst_damage, 1)  / math.floor(math.max(rst_damage, 1) + 1.05)
-- math.floor( )
-- math.ceil( )
function calc_damage(tap, cad, ndd, tar, penV, penR, finalOffensiveDV, finalOffensiveR, finalDefensiveDV, finalDefensiveDR)
local tra_cad = clip_value(1 + (cad / 1000), 1, 1.3)
local rst_damage = ((((tap * tra_cad) / (math.max(ndd, 1) * 0.35)) * math.max((1 - (tar * 0.0001)), 0.2)) + finalOffensiveDV - finalDefensiveDV) * math.max(1 + finalOffensiveR, 1) * math.max(1 - finalDefensiveDR, 0.01)
--local rst_damage = ((tap * tra_cad) / (math.max(ndd, 1) * 0.5))

if rst_damage > 4500 then
local rst_v = rst_damage * 0.1
rst_damage = 4500 + (rst_v / ((rst_v + 10000) * 0.001))
end

return math.max(rst_damage, 1)
end

-- *********************************************************************************************************************************************************************
-- 명중률 연산
function calc_attackRating(atp, dex, evp, luk, finalAtpV, finalAtpR, finalEvpV, finalEvpR)
local rst_atpStat = clip_value((dex / (dex + 70)) * 0.05, 0, 0.05)
local rst_evpStat = clip_value((luk / (luk + 70)) * 0.05, 0, 0.05)
local rst_hitRate = ((atp - 37) / (evp + (atp * 0.01))) * 1.74

return math.max(0.1, rst_hitRate + rst_atpStat - rst_evpStat)
end

-- *********************************************************************************************************************************************************************
function calc_fallDamage(mhpV, fallDistance)
local rst_damage = (mhpV * 7 * ((fallDistance - 750) / 150)) / 100
return math.max(rst_damage, 0)
end

-- *********************************************************************************************************************************************************************
-- UGC 마켓에 등록할 때 등록 수수료
-- saleCount 유저가 설정한 판매 개수
function calc_ugcshopRegisterCost(salePrice, saleCount)
return saleCount * 100;
end

-- *********************************************************************************************************************************************************************
-- UGC 마켓에서 물건을 판매 했을 때 징수하는 판매 수수료
-- purchasePrice 판매 가격
function calc_ugcshopBuyCost(purchasePrice)
return purchasePrice * 0.5;
end

-- *********************************************************************************************************************************************************************
-- memberCount같은 맵에 존재하는 파티 멤버 수에 따라 메소 보너스
function calcPartyMoneyRate(memberCount)
if memberCount == 1 then
return 1.0
elseif memberCount == 2 then
return 1.1
elseif memberCount == 3 then
return 1.15
elseif memberCount == 4 then
return 1.25
end

return 0
end

--  킬카운트 계산
function calcKillCount(myLevel, targetLevel, term, killCount)
if term < 5000 then
local diffLevel = math.abs(myLevel - targetLevel)
if diffLevel <= 5 then
killCount = killCount + 1
end
else
killCount = 1
end
return killCount
end

--  연속 킬카운트 시 증가 exp비율
function calcKillCountBonusExpRate(killCount)
if killCount > 100 then
return 0.15
elseif killCount > 50 then
return 0.1
elseif killCount > 40 then
return 0.07
elseif killCount > 30 then
return 0.04
elseif killCount > 20 then
return 0.01
elseif killCount > 10 then
return 0
end

return 0
end

--  연속 킬카운트 grade
function calcKillCountGrade(killCount)
if killCount > 50 then
return 2
elseif killCount > 20 then
return 1
end
return 0
end

--  킬카운트 메세지
function calcKillCountMsg(killCount)
if killCount == 30 then
return "s_killcount_msg1"
elseif killCount == 40 then
return "s_killcount_msg2"
elseif killCount == 50 then
return "s_killcount_msg3"
elseif killCount == 100 then
return string.format("s_killcount_msg%d",math.random(4,5))
end

return ""
end

-- 제자리 부활에 드는 메소
function calcRevivalPrice(level)
if level <= 8 then
return 0
else
return level * 10
end
end

--  월드맵에서 맵간 이동할 때 드는 메소

function calcMoveFieldPrice(level, jobCode)
if level <= 10 then
return 50
else
return 200
end
end

-- 몬스터가 피격 동작을 취하는 빈도
function calcHitMotion(boss, Critical, damage, maxHP, level)

    hitMotion = 1

if boss == 1 then
hitMotion = 0


--elseif level < 10 then
--if Critical == 1 then
--hitMotion = 1
--elseif math.random(0, 100) <= 100 then
--hitMotion = 1
--end
--else
--if Critical == 1 then
--hitMotion = 1
--elseif math.random(0, 100) <= 50 then
--hitMotion = 1
--end
end

return hitMotion
end

--  UGC Banner Price
function calcBannerPrice(adWorth, bannerDay)
return 10 * adWorth * bannerDay
end

--  Send Mail Fee
--  수수료 최대 금액이 int 이므로 INT_MAX (2,147,483,647)를 넘으면 안된다.
function calcSendMailFee(attachedItemCount, attachedMeso)
local defaultFee = 10;
local itemFee = attachedItemCount * 100
local mesoFee = 0

if attachedMeso == 0 then
mesoFee = 0
elseif attachedMeso <= 100 then
mesoFee = 1
else
mesoFee = attachedMeso * 1 / 100
end

return defaultFee + itemFee + mesoFee
end

--몬스터 자동스폰 가중치 계산
function calcNpcSpawnWeight(mainTagCount, subTagCount, rareDegree, difficultyDiff)
local weightMain = 0
local weightSub = 0
local weightRareDegree = 0
local weightDifficulty = 0

if mainTagCount == 0 then
weightMain = 1
else
weightMain = (mainTagCount + 1) * 20   --5에서 20으로 올림 (테스트를 위해)
end

if subTagCount == 0 then
weightSub = 1
else
weightSub = (subTagCount + 1) * 1
end

weightRareDegree = rareDegree * 0.01

if difficultyDiff > 10 then
weightDifficulty = 1
else
weightDifficulty = 12 - difficultyDiff
end

return weightMain + weightSub + weightRareDegree + weightDifficulty
end

--  부활 패널티 비용
function calcResolvePaneltyPrice(level, paneltyCount)
return 30 * level * paneltyCount
end

-- 테스트 목적으로 추가 by ksjeong
function testLua(a, b)
--   testtesttest()
--   error(100)
--   error('err100')
   c = a + b
   return c, "test is ok..."
end

-- ********************************************************************************
-- 매력 관련 패널티 세팅하는 테이블
-- added by ksjeong

activity = {}
activity.dead = {}
activity.dead.penalty = {}
activity.dead.penalty.timeSpan = 15 * 60-- 사망 후 카운트 되는 패널티 타임 (초 단위)
activity.dead.penalty.defaultPoint = 1-- 사망 시 감소하는 기본 성취도
activity.dead.penalty.maxPoint = 5-- 최대 누적 가능 패널티

function getActivityDeadPenaltyTime()
   return activity.dead.penalty.timeSpan
end

function getActivityDeadPenaltyDefaultPoint()
   return activity.dead.penalty.defaultPoint
end

function getActivityDeadPenaltyMaxPoint()
   return activity.dead.penalty.maxPoint
end

function getActivityDeadPenaltyConstant()
   return activity.dead.penalty.timeSpan, activity.dead.penalty.defaultPoint, activity.dead.penalty.maxPoint
end

function getDeadPenalty(beginDate, expireDate, point)
   local curTime, remainTime

   curTime = os.time()

   local penaltyInfo = activity.dead.penalty

   if beginDate == 0 then
  beginDate = curTime
  remainTime = 0
  return remainTime, beginDate, expireDate, point
   end

   if expireDate == 0 then
  expireDate = curTime + penaltyInfo.timeSpan
   end

   if expireDate > curTime then
  point = math.min(point + 1, penaltyInfo.maxPoint);
  remainTime = expireDate - curTime
   end

   return remainTime, beginDate, expireDate, point
end

-- 매력 포인트 구간을 설정하는 테이블
scoreRegion = {}

scoreRegion[1] = {}
scoreRegion[1].min = 0
scoreRegion[1].max = 29
scoreRegion[1].exp = 18

scoreRegion[2] = {}
scoreRegion[2].min = 30
scoreRegion[2].max = 39
scoreRegion[2].exp = 28

scoreRegion[3] = {}
scoreRegion[3].min = 40
scoreRegion[3].max = 49
scoreRegion[3].exp = 216

scoreRegion[4] = {}
scoreRegion[4].min = 50
scoreRegion[4].max = 59
scoreRegion[4].exp = 329

scoreRegion[5] = {}
scoreRegion[5].min = 60
scoreRegion[5].max = 79
scoreRegion[5].exp = 410

scoreRegion[6] = {}
scoreRegion[6].min = 80
scoreRegion[6].max = 99
scoreRegion[6].exp = 1516

scoreRegion[7] = {}
scoreRegion[7].min = 100
scoreRegion[7].max = 100
scoreRegion[7].exp = 38400

-- ********************************************************************************
-- 실제 매력 포인트가 저장되는 테이블
activityExpTable = {}

-- 매력 포인트 테이블 빌드 함수
function buildActivityExpTable()
   for i = 1, #scoreRegion do
     for j = scoreRegion[i].min, scoreRegion[i].max do
activityExpTable[j] = scoreRegion[i].exp
  end
   end
end

-- 매력 포인트 테이블 빌드 함수 호출
buildActivityExpTable()

-- 매력 1당 필요 경험치를 구하는 함수
function getActivityExp(lv)
   local exp = activityExpTable[lv]
   if (exp == nil) then
  exp = 0
   end
   return exp
end

-- 매력 포인트 테스트 함수
-- print (getActivityExp(100))
-- ********************************************************************************

function testActivityLevel(curLv, curExp)
   local addLevel = 0
   local level = 0
   local next = getActivityExp(0)

   while next > 0 and next <= curExp do
  curExp = curExp - next
  level = level + 1
  if level > curLv then
addLevel = addLevel + 1
  end
  next = getActivityExp(level)
   end

   local up = addLevel > 0
   if up then
  level = curLv + addLevel
  level = math.min(level, 100)
   end

   level = math.max(level, 30)
   return level
end

-- print (getActivityExp(1))
-- print (getActivityExp(2))
-- print (getActivityExp(3))
-- print (getActivityExp(4))
-- print (testActivityLevel(2, 80))


-- ********************************************************************************
-- 게임에 접속하면 매일 획득할 수 있는 경험치
activity.attend = {}
activity.attend.exp = {}
activity.attend.exp.baseHour = 6-- 리셋되는 시각 (0 ~ 23)
activity.attend.exp.timeSpan = 24*60*60-- 반복 주기를 시*분*초으로 계산하고 초 단위
activity.attend.exp.attendExp = 10-- 획득할 수 있는 생활 경험치
activity.attend.exp.increaseExp = 1-- 연속 접속할 때 가중치
activity.attend.exp.maxBonus = 30-- 최대 보너스 제한

function getPlayExp(lastTime, bonus)
   local exp = 0
   local curTime, prevTime, nextTime, expireTime
   curTime = os.time()

   local now = os.date("*t", curTime)
   local dawn = false

   local EventInfo = activity.attend.exp

   if now.hour < EventInfo.baseHour then
  dawn = true
   end

   nextTime = os.time{year=now.year, month=now.month, day=now.day, hour=EventInfo.baseHour}

   if dawn then
  nextTime = nextTime - EventInfo.timeSpan
   end

   prevTime = nextTime - EventInfo.timeSpan

   expireTime = nextTime + EventInfo.timeSpan - curTime

   if lastTime >= nextTime then
  -- already executed
  return false, exp, bonus, curTime, expireTime
   end

   if lastTime >= prevTime and lastTime < nextTime then
  bonus = math.min(bonus + 1, EventInfo.maxBonus)
   else
  bonus = 0
   end

   exp = EventInfo.attendExp + bonus * EventInfo.increaseExp

   return true, exp, bonus, curTime, expireTime
end

function getDate(year, month, day, hour, min)
   local tmp = os.time{year=year, month=month, day=day, hour=hour, min=min}
   return tmp
end

function getDateFromUnixTime(unixTime)
   local tmp = os.date("*t", unixTime)
   return tmp.year, tmp.month, tmp.day, tmp.hour, tmp.min, unixTime
end

-- print(getDate(2014, 1, 9, 6, 0))
-- print(getDate(2014, 1, 9, 18, 0))
-- print(getDateFromUnixTime(1389128400))
-- print(getDateFromUnixTime(1389042000))
-- print(getDateFromUnixTime(1389042002))
-- print (getPlayExp(1389128400, 1))
-- print (getPlayExp(1389042000, 1))
-- print (getPlayExp(1389042001, 1))
-- print (getPlayExp(0, 1))
-- print (getPlayExp(0, 0))
-- print (getPlayExp(1389214800, 1))
-- print (getPlayExp(1389258000, 1))

-- ********************************************************************************
-- 게임 미 접속 패널티
activity.unattend = {}
activity.unattend.penalty = {}
activity.unattend.penalty.defaultPoint = 1-- 미 접속 시 감소하는 기본 성취도
activity.unattend.penalty.bonusPoint = 1-- 연속해서 접속하지 않을 때 감소하는 성취도 (2일 연속 +1, 3일 연속이면 +2)
activity.unattend.penalty.maxPoint = 30-- 최대 감소하는 성취도
activity.unattend.penalty.timeSpan = 24*60*60-- 접속 체크 기간 초 단위 (기본 하루 24시간)

function getPlayPenalty(lastTime, point, expireTime)
   local curTime, remainTime, periodSec, periodDay
   curTime = os.time()

   local penaltyInfo = activity.unattend.penalty

   if lastTime == 0 then
  remainTime = 0
  return point, remainTime, expireTime
   end

   if expireTime > curTime then
  remainTime = expireTime - curTime
  return point, remainTime, expireTime
   end

   periodSec = curTime - lastTime
   periodDay = periodSec / penaltyInfo.timeSpan
   periodDay = math.floor(periodDay)
   remainTime = 0
   expireTime = 0
   point = 0

   if periodDay >= 1 then
  point = point + penaltyInfo.defaultPoint
  point = point + (periodDay - 1) * penaltyInfo.bonusPoint
  point = math.min(point, penaltyInfo.maxPoint)
  remainTime = penaltyInfo.timeSpan
  expireTime = curTime + penaltyInfo.timeSpan
   end

   return point, remainTime, expireTime
end

-- ********************************************************************************
-- 드롭 수량 제한하는 아이템을 우선 뽑을 순서 결정하는 시스템.

function getNpcRewardArrangeWeight(monsterLevel, userLevel)

local defaultWeight = 100
if monsterLevel - 3 <= userLevel then-- 기본 가중치를 적용받을 레벨대.
return defaultWeight
end

if monsterLevel - userLevel >= 20 then-- 몬스터와 유저 레벨의 차이를 판단.
return defaultWeight / (monsterLevel - userLevel)
end

return 1-- 나머지 레벨들은 가중치를 1로 적용. 0을 넣을 경우 보상에서 완전 제외됨으로 보상을 줄 기회를 주려면 무조건 1 이상
end

function getNow()
   return os.time()
end

-- print(getDate(2014, 1, 10, 6, 0)) -- 1389301200
-- print(getDate(2014, 1, 10, 18, 0)) -- 1389344400
-- print(getDateFromUnixTime(1389128400)) -- 2014/01/08 06:00
-- print(getDateFromUnixTime(1389344400)) -- 2014/01/10 18:00
-- print(getDateFromUnixTime(1389301200)) -- 2014/01/10 06:00
-- print(getPlayPenalty(1389128400, 10, 1389301200)) -- 2014/01/08 06::00, 01/10 06:00
-- print(getPlayPenalty(1389128400, 10, 1389344400)) -- 2014/01/08 06:00, 01/10 18:00
-- print(getPlayPenalty(1357592400, 0, 1389344400))
-- print(getPlayPenalty(1389301200, 0, 1389344400))
-- print(getPlayPenalty(1389128400, 10, 1389344400))
-- print(getPlayPenalty(1357592400, 10, 1389344400))
-- print(getPlayPenalty(1389301200, 10, 1389344400))
-- print(getPlayPenalty(0, 0, 0))

-- ********************************************************************************
-- 매시브 이벤트 참여
activity.massive = {}
activity.massive.exp = {}
activity.massive.exp.attendPoint = 10-- 매시브 이벤트에 참가하면 얻을 수 있는 생활 경험치
activity.massive.exp.winPoint = 100-- 우승하면 획득할 수 있는 생활 경험치

function getMassiveExpPoint(winFlag)
   local bonusInfo = activity.massive.exp
   if winFlag then
  return bonusInfo.winPoint
   else
  return bonusInfo.attendPoint
   end
end

-- print(getMassiveExpPoint(true))
-- print(getMassiveExpPoint(false))

-- ********************************************************************************
-- 플레이어 킬 패널티
activity.kill = {}
activity.kill.penalty = {}
activity.kill.penalty.defaultPoint = 5-- 다른 플레이어 킬에 따른 매력 포인트 감소
activity.kill.penalty.increasePoint = 1-- 누적 킬 수 증가에 따른 가중치
activity.kill.penalty.maxPoint = 10-- 감소하는 최대 한도를 설정
activity.kill.penalty.maxKillCount = 10-- 누적 킬 카운트의 최대 한도

function getPKPenalty(killCount)
   local point = 0
   local penaltyInfo = activity.kill.penalty

   point = point + penaltyInfo.defaultPoint
   point = point + killCount * penaltyInfo.increasePoint
   point = math.min(point, penaltyInfo.maxPoint)

   killCount = killCount + 1
   killCount = math.min(killCount, penaltyInfo.maxKillCount)

   return point, killCount
end

-- print(getPKPenalty(0))
-- print(getPKPenalty(3))
-- print(getPKPenalty(10))
-- print(getPKPenalty(20))
-- print(getPKPenalty(15))


-- ********************************************************************************
--  택시 사용 비용

function calcTaxiCharge(distance,level) -- distance; 거쳐가는 맵 수, level; 캐릭터 레벨
   --if level < 11 then
   --    return distance * 10
   --end

   return math.floor((((distance * 200) * ((35 + (level * 3.6)) / (35 + level))) / 10) + 0.5) * 10
   --return distance * 200
end
-- ********************************************************************************
引用網址:https://home.gamer.com.tw/TrackBack.php?sn=2600106
All rights reserved. 版權所有,保留一切權利

相關創作

留言共 0 篇留言

我要留言提醒:您尚未登入,請先登入再留言

1喜歡★Forad 可決定是否刪除您的留言,請勿發表違反站規文字。

前一篇:楓之谷2--Alpha測... 後一篇:楓之谷2--Alpha測...

追蹤私訊切換新版閱覽

作品資料夾

SALOL~~
望德勒斯圖書館更新中~看更多我要大聲說1小時前


face基於日前微軟官方表示 Internet Explorer 不再支援新的網路標準,可能無法使用新的應用程式來呈現網站內容,在瀏覽器支援度及網站安全性的雙重考量下,為了讓巴友們有更好的使用體驗,巴哈姆特即將於 2019年9月2日 停止支援 Internet Explorer 瀏覽器的頁面呈現和功能。
屆時建議您使用下述瀏覽器來瀏覽巴哈姆特:
。Google Chrome(推薦)
。Mozilla Firefox
。Microsoft Edge(Windows10以上的作業系統版本才可使用)

face我們了解您不想看到廣告的心情⋯ 若您願意支持巴哈姆特永續經營,請將 gamer.com.tw 加入廣告阻擋工具的白名單中,謝謝 !【教學】