• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

Lua npc

alcapone

Member
Joined
Jan 13, 2021
Messages
231
Reaction score
17
I have a doubt in this part

each item the player gets 1 achievement but I don't know how to check this

local IDS = {
DREAM_MATTER = 22397,
CLUSTER_OF_SOLACE = 22396,

--weapons
CRUDE_UMBRAL_BLADE = 22398,
UMBRAL_BLADE = 22399,
UMBRAL_MASTER_BLADE = 22400,

CRUDE_UMBRAL_SLAYER = 22401,
UMBRAL_SLAYER = 22402,
UMBRAL_MASTER_SLAYER = 22403,

CRUDE_UMBRAL_AXE = 22404,
UMBRAL_AXE = 22405,
UMBRAL_MASTER_AXE = 22406,

CRUDE_UMBRAL_CHOPPER = 22407,
UMBRAL_CHOPPER = 22408,
UMBRAL_MASTER_CHOPPER = 22409,

CRUDE_UMBRAL_MACE = 22410,
UMBRAL_MACE = 22411,
UMBRAL_MASTER_MACE = 22412,

CRUDE_UMBRAL_HAMMER = 22413,
UMBRAL_HAMMER = 22414,
UMBRAL_MASTER_HAMMER = 22415,

CRUDE_UMBRAL_BOW = 22416,
UMBRAL_BOW = 22417,
UMBRAL_MASTER_BOW = 22418,

CRUDE_UMBRAL_CROSSBOW = 22419,
UMBRAL_CROSSBOW = 22420,
UMBRAL_MASTER_CROSSBOW = 22421,

CRUDE_UMBRAL_SPELLBOOK = 22422,
UMBRAL_SPELLBOOK = 22423,
UMBRAL_MASTER_SPELLBOOK = 22424
}

local TYPES = {
SWORD = 1,
AXE = 2,
CLUB = 3,
BOW = 4,
CROSSBOW = 5,
SPELLBOOK = 6
}

local SUB_TYPES = {
BLADE = 1,
SLAYER = 2,
AXE = 3,
CHOPPER = 4,
MACE = 5,
HAMMER = 6,
BOW = 7,
CROSSBOW = 8,
SPELLBOOK = 9
}

local ACTION = {
CREATE = 1,
IMPROVE = 2,
TRANSFORM = 3
}
Lua:
elseif action[cid] == ACTION.TRANSFORM then --transform

            local oldItemId = (weapon[cid] == TYPES.SWORD and (weapon_sub[cid] == SUB_TYPES.BLADE and IDS.UMBRAL_BLADE or IDS.UMBRAL_SLAYER) or weapon[cid] == TYPES.AXE and (weapon_sub[cid] == SUB_TYPES.AXE and IDS.UMBRAL_AXE or IDS.UMBRAL_CHOPPER) or weapon[cid] == TYPES.CLUB and (weapon_sub[cid] == SUB_TYPES.MACE and IDS.UMBRAL_MACE or IDS.UMBRAL_HAMMER) or weapon[cid] == TYPES.BOW and IDS.UMBRAL_BOW or weapon[cid] == TYPES.CROSSBOW and IDS.UMBRAL_CROSSBOW or weapon[cid] == TYPES.SPELLBOOK and IDS.UMBRAL_SPELLBOOK or false)

            local newItemId =  (oldItemId and oldItemId + 1 or false)

            if player:getItemCount(IDS.CLUSTER_OF_SOLACE) >= Config.Transform.Clusters then

                if newItemId and oldItemId then

                    if player:getItemCount(oldItemId) > 0 then

                        if math.random(100) <= Config.Transform.Chance then

                            player:removeItem(oldItemId, 1)

                            player:addItem(newItemId)

                            player:removeItem(IDS.CLUSTER_OF_SOLACE, Config.Transform.Clusters)

                         

                             -- player:addAchievement('Umbral Archer')

                            --player:addAchievement('Umbral Berserker')

                            --player:addAchievement('Umbral Bladelord')

                            --player:addAchievement('Umbral Brawler')

                        --    player:addAchievement('Umbral Executioner')

                        --    player:addAchievement('Umbral Harbringer')

                        --    player:addAchievement('Umbral Headsman')

                        --    player:addAchievement('Umbral Marksman')

                        --    player:addAchievement('Umbral Master')

                        --    player:addAchievement('Umbral Swordsman')

                         

                            npcHandler:say("Your dreams are strong, the transforming was successful. Take your " .. ItemType(newItemId):getName() .. ".", cid)

                        else

                            npcHandler:say("Oh no! The process failed.", cid)

                            local rand = math.random(100)

                            if Config.Transform.BreakChance <= rand then

                                player:removeItem(oldItemId, 1)

                            else

                                player:removeItem(oldItemId, 1)

                                player:addItem(oldItemId - 1, 1)

                                player:removeItem(IDS.CLUSTER_OF_SOLACE, Config.Transform.Clusters / 2)

                            end

                        end

                    else

                        npcHandler:say("You do not have " .. ItemType(oldItemId):getArticle() .. " " .. ItemType(oldItemId):getName() .. " with you.", cid)

                    end

                else

                    npcHandler:say("Something weird happened! You should contact a gamemaster.", cid)

                end

            end

        end

        npcHandler:releaseFocus(cid)

        npcHandler:resetNpc()

    end

end
 
Top