1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
function npcConversationCommit (npc, handler, group, question)
if (question == "bell") then
--Check if we have it already
local hasBell = LuaInterface_GroupGetObjects (group, "Bell");
if (hasBell > 0) then
return "You already have it! Go see Annon now", 1, true;
end
-- Local variables
local maxMonsters = 15;
local key = "getBell";
-- First check if we have already asked for the bell
local hasKilled = LuaInterface_GroupGetKeyValue (group, "getBell");
-- Load up the castle 2 map
local handler = LuaInterface_MapHandlerLoadMap ("../ULTIMA5/CASTLE.DAT 2", group);
if (hasKilled == 0) then
-- Add one so we know
LuaInterface_GroupIncrementKeyValue (group, key, 1);
-- Add monsters to map
luaAddMonsters (handler, "getBell", maxMonsters);
return "To get the bell, kill the monsters in West Brittany and come see me", 1, true
else
-- It's not 0 so we should have a number of monsters still to kill
hasKilled = hasKilled - 1;
local shouldKill = maxMonsters - hasKilled;
if (shouldKill ~= 0) then
-- How many are left in the map?
local stillHave = LuaInterface_MapHandlerCountAnimatedObjectKeys (handler, "getBell");
if (stillHave < shouldKill) then
luaAddMonsters (handler, key, shouldKill - stillHave);
end
return "To get the bell, you still need to kill "..shouldKill.." monsters", 1, true
else
-- Add the object to the map
local object = LuaInterface_ObjectFactoryGetObject ("Bell");
-- Now add object
LuaInterface_MapHandlerAddHiddenObject (handler, object, 1, 2, 0);
return "The monsters are gone, you can find the bell under the top left grave", 1, true
end
end
end
return "", 0, false
end |
Partager