I am a newbie to programming, but I thought I'd try my hand at trying to script an NPC for DS.
My script has been tested on a private server and works as intended.
I'm eager to hear any feedback and tips on it.
Code: Select all
----------------------------------------------------------------------
-- Quest: Undying Flames
-- Area: San d'Oria
-- Quest ID: 26
-- Quest NPC: Pagisalis
-- Starts: Undying Flames
-- Involved in: Enveloped in Darkness
-- @zone 231
-- @pos 138 6 131
----------------------------------------------------------------------
package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil;
----------------------------------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/globals/shop");
require("scripts/globals/quests");
require("scripts/zones/Northern_San_dOria/TextIDs");
----------------------------------------------------------------------
--OnTrade Action
----------------------------------------------------------------------
function onTrade(player,npc,trade)
-- Npc used in AF quest
if(player:getQuestStatus(SANDORIA,ENVELOPED_IN_DARKNESS) == 3) then
count = trade:getItemCount();
VelvetCloth = trade:hasItemQty(828,1);
if(VelvetCloth == true and count == 1) then
player:startevent(0x0025);--start RDM AF feet CS
end
end
--Now script this quest
if(player:getQuestStatus(SANDORIA,UNDYING_FLAMES) == QUEST_ACCEPTED) then
count = trade:getItemCount();
Beeswax = trade:hasItemQty(913,2);
if(Beeswax == true and count == 2) then
if(player:getFreeSlotsCount() > 0) then
player:tradeComplete();
player:startEvent(0x0233);--quest complete text
else
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,13211);
end
else
player:startEvent(0x0234);--npc responding that trade items are wrong
end
end
end;
-----------------------------------------------------------------------
--onTrigger Action
-----------------------------------------------------------------------
function onTrigger(player,npc)
UndyingFlames = player:getQuestStatus(SANDORIA,UNDYING_FLAMES);
EnvelopedInDarkness = player:getQuestStatus(SANDORIA,ENVELOPED_IN_DARKNESS);
--Clicking on npc before and after trading in enveloped in darkness
-- if(EnvelopedInDarkness = 2 or 3) then -- I wish it worked this easily ;_; It needs more text
if(EnvelopedInDarkness == 2 or EnvelopedInDarkness == 3) then -- = is setting a variable, == is checking if it matches a value
player:startEvent(0x0030);--quest text for instructing player
elseif(EnvelopedInDarkness >= 4) then
player:startEvent(0x003A);--text after trade for EiD has been made
--clicking on npc without undying flames active
elseif(UndyingFlames == 0) then
player:startEvent(0x0232);--event for starting quest
elseif(UndyingFlames == 1) then
player:startEvent(0x0235);--event for talking to npc with quest accepted
elseif(UndyingFlames == 2) then
player:startEvent(0x0236);--changed text for talking after the quest is complete
end
end
----------------------------------------------------------------------
--onEventFinish
----------------------------------------------------------------------
function onEventFinish(player,csid,option)
UndyingFlames = player:getQuestStatus(SANDORIA,UNDYING_FLAMES);
EnvelopedInDarkness = player:getQuestStatus(SANDORIA,ENVELOPED_IN_DARKNESS);
--Quest progression for Enveloped in Darkness
if(csid == 0x0030) then
player:setVar("QuestEnvelopedInDarknessVar",3);
elseif(csid == 0x0025) then
player:setVar("QuestEnvelopedInDarknessVar",4)
player:addItem(14093);--give player RDM feet
player:messageSpecial(ITEM_OBTAINED,14093)
--Quest progression for Undying Flames
elseif(csid == 0x0232 and option == 0) then
player:setVar("QuestUndyingFlamesVar", 1);
player:addQuest(SANDORIA,UNDYING_FLAMES);
elseif(csid == 0x0233) then
player:addFame(SANDORIA,SAN_FAME*30);
player:addItem(13211);
player:messageSpecial(ITEM_OBTAINED,13211);
player:setTitle(FAITH_LIKE_A_CANDLE);
player:completeQuest(SANDORIA,UNDYING_FLAMES);
end
end
Here is the file for easy download.
Here's hoping to many more successful codes!