samandriel
Active Member
- Joined
- Oct 19, 2016
- Messages
- 242
- Solutions
- 1
- Reaction score
- 46
I'm trying to bring Dawnport to 8.6 on my 0.4 (https://github.com/Fir3element/3777/blob/master/src/luascript.cpp)
It's already changing vocation, give items...
But there is only one thing it not working:
When players change vocation i want to convert skills, i mean a mage ml 10, change to knight he cant still with ml 10, same to knight shielding 40, cant be mage shielding 40
What i tried so far? zxmatzx gave me the idea to use:
getPlayerSkillTries(cid, skill) and getPlayerRequiredSkillTries(cid, skillId, skillLevel)
But its not working at all, when players change vocation it always reseting skills to the start
Why?
Full code:
It's already changing vocation, give items...
But there is only one thing it not working:
When players change vocation i want to convert skills, i mean a mage ml 10, change to knight he cant still with ml 10, same to knight shielding 40, cant be mage shielding 40
What i tried so far? zxmatzx gave me the idea to use:
getPlayerSkillTries(cid, skill) and getPlayerRequiredSkillTries(cid, skillId, skillLevel)
Code:
-- | skills convert |
-- get skill points
local SKILL_SHIELD_POINTS = getPlayerSkillTries(cid, SKILL_SHIELD)
local SKILL_DISTANCE_POINTS = getPlayerSkillTries(cid, SKILL_DISTANCE)
local SKILL_AXE_POINTS = getPlayerSkillTries(cid, SKILL_AXE)
local SKILL_SWORD_POINTS = getPlayerSkillTries(cid, SKILL_SWORD)
local SKILL_CLUB_POINTS = getPlayerSkillTries(cid, SKILL_CLUB)
-- reset skills
doPlayerSetMagicLevel(cid, 0)
doPlayerSetSkillLevel(cid, SKILL_SHIELD, 10)
doPlayerSetSkillLevel(cid, SKILL_DISTANCE, 10)
doPlayerSetSkillLevel(cid, SKILL_AXE, 10)
doPlayerSetSkillLevel(cid, SKILL_SWORD, 10)
doPlayerSetSkillLevel(cid, SKILL_CLUB, 10)
-- set skill points back
doPlayerAddSkillTry(cid, SKILL_SHIELD, SKILL_SHIELD_POINTS)
doPlayerAddSkillTry(cid, SKILL_DISTANCE, SKILL_DISTANCE_POINTS)
doPlayerAddSkillTry(cid, SKILL_AXE, SKILL_AXE_POINTS)
doPlayerAddSkillTry(cid, SKILL_SWORD, SKILL_SWORD_POINTS)
doPlayerAddSkillTry(cid, SKILL_CLUB, SKILL_CLUB_POINTS)
But its not working at all, when players change vocation it always reseting skills to the start
Why?
Full code:
Code:
-- olhar o cap changing
local tile = {
--[actionid] = {vocation id}
[65530] = {
vocid = 1,
weaponID = 2190, -- wand of vortex
extraItems = {
{itemID = 2260, count = 50}, -- blank rune
{itemID = 2287, count = 30}, -- lmm
{itemID = 2302, count = 15} -- FIREBALL
}
},
[65529] = {
vocid = 2,
weaponID = 2182, -- snakebite rod
extraItems = {
{itemID = 2260, count = 50}, -- blank rune
{itemID = 2287, count = 30}, -- lmm
{itemID = 2265, count = 5}, -- IH
{itemID = 2302, count = 10} -- FIREBALL
}
},
[65528] = {
vocid = 3,
weaponID = 2456, -- bow
extraItems = {
{itemID = 2260, count = 10}, -- blank rune
{itemID = 2544, count = 100}, -- arrows
{itemID = 2389, count = 3}, -- spear
{itemID = 2265, count = 5}, -- IH
{itemID = 2287, count = 5}, -- LMM
{itemID = 2302, count = 5} -- FIREBALL
}
},
[65527] = {
vocid = 4,
extraItems = {
{itemID = 2379, count = 1}, -- sword
{itemID = 2382, count = 1}, -- axe
{itemID = 2380, count = 1}, -- club
{itemID = 2265, count = 10}, -- IH
{itemID = 2287, count = 5}, -- LMM
{itemID = 2302, count = 3} -- FIREBALL
}
}
}
function onStepIn(cid, item, position, fromPosition)
local r = tile[item.actionid]
if not r then
return true
end
local townid = 7
local pos = {x= 392, y=929, z=6}
local needcap
local extralvls = getPlayerLevel(cid) - 1
local vocation
local cap
local hp
local mp
-- get skill points in current vocation
local SKILL_SHIELD_POINTS = getPlayerRequiredSkillTries(cid, SKILL_SHIELD, getPlayerSkillLevel(cid, SKILL_SHIELD, true))
local SKILL_DISTANCE_POINTS = getPlayerRequiredSkillTries(cid, SKILL_DISTANCE, getPlayerSkillLevel(cid, SKILL_DISTANCE, true))
local SKILL_AXE_POINTS = getPlayerRequiredSkillTries(cid, SKILL_AXE, getPlayerSkillLevel(cid, SKILL_AXE, true))
local SKILL_SWORD_POINTS = getPlayerRequiredSkillTries(cid, SKILL_SWORD, getPlayerSkillLevel(cid, SKILL_SWORD, true))
local SKILL_CLUB_POINTS = getPlayerRequiredSkillTries(cid, SKILL_CLUB, getPlayerSkillLevel(cid, SKILL_CLUB, true))
if item.actionid == 65530 then -- sorc
if getPlayerVocation(cid) == 1 then --already sorc
doTeleportThing(cid, fromPosition)
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
return true
end
doPlayerSetVocation(cid, 1)
needcap = 88
hp = (185) + (extralvls * 5)
mp = (35) + (extralvls * 30)
cap = (400) + (extralvls * 10)
---
elseif item.actionid == 65529 then -- druid
if getPlayerVocation(cid) == 2 then --already druid
doTeleportThing(cid, fromPosition)
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
return true
end
doPlayerSetVocation(cid, 2)
needcap = 91
hp = (185) + (extralvls * 5)
mp = (35) + (extralvls * 30)
cap = (400) + (extralvls * 10)
---
elseif item.actionid == 65528 then -- pally
if getPlayerVocation(cid) == 3 then --already pally
doTeleportThing(cid, fromPosition)
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
return true
end
doPlayerSetVocation(cid, 3)
needcap = 122
hp = (185) + (extralvls * 10)
mp = (35) + (extralvls * 15)
cap = (400) + (extralvls * 20)
---
elseif item.actionid == 65527 then -- kina
if getPlayerVocation(cid) == 4 then --already knight
doTeleportThing(cid, fromPosition)
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
return true
end
doPlayerSetVocation(cid, 4)
needcap = 44
hp = (185) + (extralvls * 15)
mp = (35) + (extralvls * 5)
cap = (400) + (extralvls * 25)
---
end
-- add stuff
setCreatureMaxHealth(cid, hp)
setCreatureMaxMana(cid, mp)
doCreatureAddHealth(cid, getCreatureMaxHealth(cid), false)
doCreatureAddMana(cid, getCreatureMaxMana(cid), false)
doTeleportThing(cid, pos)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
doPlayerSetTown(cid, townid)
-- cap convert
doPlayerSetMaxCapacity(cid, cap)
-- | skills convert |
-- reset skills
doPlayerSetMagicLevel(cid, 0)
doPlayerSetSkillLevel(cid, SKILL_SHIELD, 10)
doPlayerSetSkillLevel(cid, SKILL_DISTANCE, 10)
doPlayerSetSkillLevel(cid, SKILL_AXE, 10)
doPlayerSetSkillLevel(cid, SKILL_SWORD, 10)
doPlayerSetSkillLevel(cid, SKILL_CLUB, 10)
-- set skill points back
doPlayerAddSkillTry(cid, SKILL_SHIELD, SKILL_SHIELD_POINTS)
doPlayerAddSkillTry(cid, SKILL_DISTANCE, SKILL_DISTANCE_POINTS)
doPlayerAddSkillTry(cid, SKILL_AXE, SKILL_AXE_POINTS)
doPlayerAddSkillTry(cid, SKILL_SWORD, SKILL_SWORD_POINTS)
doPlayerAddSkillTry(cid, SKILL_CLUB, SKILL_CLUB_POINTS)
-- | add items |
-- already recived
local queststatus = getPlayerStorageValue(cid, item.actionid)
if queststatus ~= -1 then
return true
end
-- dont have cap
if getPlayerFreeCap(cid) < needcap then
doTeleportThing(cid, fromPosition, false)
doSendMagicEffect(position, CONST_ME_MAGIC_BLUE)
doPlayerPopupFYI(cid, 'You need '.. needcap ..' OZ CAP to recive the items!')
return true
end
-- add items
-- weapon first
if r.weaponID then
doPlayerAddItem(cid, r.weaponID, 1)
end
-- other stuffs
if r.extraItems then
for i=1,#r.extraItems do
local item,count = r.extraItems[i].itemID, r.extraItems[i].count
doPlayerAddItem(cid, item, count)
end
end
setPlayerStorageValue(cid,item.actionid,1)
return true
end