diff options
Diffstat (limited to 'example/serverdata/scripts/npcs')
-rw-r--r-- | example/serverdata/scripts/npcs/banker.lua | 79 | ||||
-rw-r--r-- | example/serverdata/scripts/npcs/barber.lua | 139 | ||||
-rw-r--r-- | example/serverdata/scripts/npcs/debugger.lua | 100 | ||||
-rw-r--r-- | example/serverdata/scripts/npcs/emotemaker.lua | 45 | ||||
-rw-r--r-- | example/serverdata/scripts/npcs/healer.lua | 21 | ||||
-rw-r--r-- | example/serverdata/scripts/npcs/merchant.lua | 114 | ||||
-rw-r--r-- | example/serverdata/scripts/npcs/postman.lua | 30 | ||||
-rw-r--r-- | example/serverdata/scripts/npcs/shaker.lua | 48 |
8 files changed, 0 insertions, 576 deletions
diff --git a/example/serverdata/scripts/npcs/banker.lua b/example/serverdata/scripts/npcs/banker.lua deleted file mode 100644 index 4e048653..00000000 --- a/example/serverdata/scripts/npcs/banker.lua +++ /dev/null @@ -1,79 +0,0 @@ ----------------------------------------------------------- --- Banker Function -- ----------------------------------------------------------------------------------- --- Copyright 2008 The Mana World Development Team -- --- -- --- This file is part of The Mana World. -- --- -- --- The Mana World is free software; you can redistribute it and/or modify it -- --- under the terms of the GNU General Public License as published by the Free -- --- Software Foundation; either version 2 of the License, or any later version. -- ----------------------------------------------------------------------------------- - -function Banker(npc, ch) - if mana.being_get_gender(ch) == GENDER_MALE then - do_message(npc, ch, "Welcome to the bank, sir!") - elseif mana.being_get_gender(ch) == GENDER_FEMALE then - do_message(npc, ch, "Welcome to the bank, madam!") - else - do_message(npc, ch, "Welcome to the bank... uhm... person of unspecified gender!") - end - local account = tonumber(get_quest_var(ch, "BankAccount")) - local result = -1 - do_wait() - - if (account == nil) then --Initial account creation, if needed - do_message(npc, ch, "Hello! Would you like to setup a bank account? There is a sign-on bonus right now!") - result = do_choice(npc, ch, "Yes", "No") - if (result == 1) then - mana.chr_set_quest(ch, "BankAccount", 5) - do_message(npc, ch, "Your account has been made. Your sign-on bonus is 5GP.") - account = 5 - end - end - - if (account ~= nil) then --If the player has an account - local money = 0 - local input = 0 - result = 1 - while (result < 3) do --While they've choosen a valid option that isn't "Never mind" - account = tonumber(get_quest_var(ch, "BankAccount")) --Why do I need to convert this? - do_message(npc, ch, "Your balance: " .. account .. ".\nYour money: " .. mana.chr_money(ch) .. ".") - result = do_choice(npc, ch, "Deposit", "Withdraw", "Never mind") - if (result == 1) then --Deposit - money = mana.chr_money(ch); - if (money > 0) then --Make sure they have money to deposit - do_message(npc, ch, "How much would you like to deposit? (0 will cancel)") - input = do_ask_integer(npc, ch, 0, money, 1) - do_wait() - money = mana.chr_money(ch) - if (input > 0 and input <= money) then --Make sure something weird doesn't happen and they try to deposit more than they have - mana.chr_money_change(ch, -input) - mana.chr_set_quest(ch, "BankAccount", account + input) - do_message(npc, ch, input .. " GP deposited.") - elseif (input > money) then --Chosen more than they have - do_message(npc, ch, "You don't have that much money. But you just did....") - end - else - do_message(npc, ch, "You don't have any money to deposit!") - end - elseif (result == 2) then --Withdraw - if (account > 0) then --Make sure they have money to withdraw - do_message(npc, ch, "How much would you like to withdraw? (0 will cancel)") - input = do_ask_integer(npc, ch, 0, account, 1) - if (input > 0 and input <= account) then --Make sure something weird doesn't happen and they try to withdraw more than they have - mana.chr_money_change(ch, input) - mana.chr_set_quest(ch, "BankAccount", account - input) - do_message(npc, ch, input .. " GP withdrawn.") - elseif (input > account) then --Chosen more than they have - do_message(npc, ch, "You don't have that much in your account. But you just did....") - end - else - do_message(npc, ch, "Your account is empty!") - end - end - end --This ends the while loop - end - - do_message(npc, ch, "Thank you. Come again!") -end diff --git a/example/serverdata/scripts/npcs/barber.lua b/example/serverdata/scripts/npcs/barber.lua deleted file mode 100644 index fbb2862c..00000000 --- a/example/serverdata/scripts/npcs/barber.lua +++ /dev/null @@ -1,139 +0,0 @@ ----------------------------------------------------------- --- Barber Function -- ----------------------------------------------------------------------------------- --- Copyright 2009 The Mana World Development Team -- --- -- --- This file is part of The Mana World. -- --- -- --- The Mana World is free software; you can redistribute it and/or modify it -- --- under the terms of the GNU General Public License as published by the Free -- --- Software Foundation; either version 2 of the License, or any later version. -- ----------------------------------------------------------------------------------- - -local barber_styles = {"Flat ponytail", "Bowl cut","Combed back", "Emo", "Mohawk", - "Pompadour", "Center parting/Short and slick", "Long and slick", "Short and curly", - "Pigtails", "Long and curly", "Parted", "Perky ponytail", "Wave", "Mane", "Bun"} - -local barber_colors = {"Light brown", "Green", "Dark red", "Light purple", "Gray", "Blonde", - "Blue", "Brown", "Light Bblue", "Dark purple", "Black", "Shock white"} - -function Barber(npc, ch, data) - local style_ids = nil - local color_ids = nil - - -- If extra data was passed, let's have a look at it - if data ~= nil then - style_ids = data[1] - if #data > 1 then - color_ids = data[2] - end - end - - -- Setup up default styles (if needed) - if style_ids == nil then - style_ids = {} - for i = 1, 13 do - style_ids[i] = i - end - end - - -- Setup up default colors (if needed) - if color_ids == nil then - color_ids = {} - for i = 1, 11 do - color_ids[i] = i - end - end - - -- Nothing to show? Then we can return - if #color_ids == 0 and #style_ids == 0 then - return - end - - local result = 0 - - local styles = {} - - -- If we have style IDs, lets get their names - if #style_ids > 0 then - for i = 1, #style_ids do - styles[i] = barber_styles[style_ids[i]] - end - result = 1 - end - - local colors = {} - - -- If we have color style IDs, lets get their names - if #color_ids > 0 then - for i = 1, #color_ids do - colors[i] = barber_colors[color_ids[i]] - end - - if result == 0 then - result = 2 - else - result = 3 - end - end - - -- Choose an appropriate message - if result == 1 then - do_message(npc, ch, "Hello! What style would you like today?") - elseif result == 2 then - do_message(npc, ch, "Hello! What color would you like today?") - else - do_message(npc, ch, "Hello! What can I do for you today?") - end - - print("#styles ==", #styles) - - -- Repeat until the user selects nothing - repeat - if (result == 1) then -- Do styles - result = do_choice(npc, ch, "Bald", styles, "Surprise me", "Never mind") - - result = result -1 - - --Random - if (result == #styles + 1) then - result = math.random(#styles + 1) - 1 - print("Random") - end - - print("Style ==", result) - - if (result == 0) then - mana.chr_set_hair_style(ch, 0) - result = 1 - elseif (result <= #styles) then - mana.chr_set_hair_style(ch, style_ids[result]) - result = 1 - else --"Never mind" - result = 3 - end - elseif (result == 2) then -- Do colors - result = do_choice(npc, ch, colors, "Surprise me", "Never mind") - - --Random - if (result == #colors + 1) then - result = math.random(#colors) - end - - if (result <= #colors) then - mana.chr_set_hair_color(ch, color_ids[result - 1]) - result = 2 - else --"Never mind" - result = 3 - end - end - - -- If we have both styles and colors, show the main menu - if #styles > 0 and #colors > 0 then - result = do_choice(npc, ch, "Change my style", "Change my color", "Never mind") - end - until result >= 3 --While they've choosen a valid option that isn't "Never mind" - - -- Let's close up - do_message(npc, ch, "Thank you. Come again!") -end diff --git a/example/serverdata/scripts/npcs/debugger.lua b/example/serverdata/scripts/npcs/debugger.lua deleted file mode 100644 index 142c3fd8..00000000 --- a/example/serverdata/scripts/npcs/debugger.lua +++ /dev/null @@ -1,100 +0,0 @@ ----------------------------------------------------------- --- Seller Function Sample -- ----------------------------------------------------------------------------------- --- Copyright 2009-2010 The Mana World Development Team -- --- -- --- This file is part of The Mana World. -- --- -- --- The Mana World is free software; you can redistribute it and/or modify it -- --- under the terms of the GNU General Public License as published by the Free -- --- Software Foundation; either version 2 of the License, or any later version. -- ----------------------------------------------------------------------------------- - -function npc1_talk(npc, ch) - on_remove(ch, function() print "Player has left the map." end); - do_message(npc, ch, "Hello! I am the testing NPC.") - local rights = mana.chr_get_rights(ch); - - if (rights >= 128) then - do_message(npc, ch, "Oh mighty server administrator, how can I avoid your wrath?") - elseif (rights >= 8) then - do_message(npc, ch, "How can I be of assistance, sir gamemaster?") - elseif (rights >= 4) then - do_message(npc, ch, "What feature would you like to debug, developer?") - elseif (rights >= 2) then - do_message(npc, ch, "How can I assist you in your testing duties?") - elseif (rights >= 1) then - do_message(npc, ch, "What do you want, lowly player?") - else - do_message(npc, ch, "...aren't you supposed to be banned??") - end - - local v = do_choice(npc, ch, "Guns! Lots of guns!", - "A Christmas party!", - "To make a donation.", - "Slowly count from one to ten.", - "Tablepush Test") - if v == 1 then - do_message(npc, ch, "Sorry, this is a heroic-fantasy game, I do not have any gun.") - - elseif v == 2 then - local n1, n2 = mana.chr_inv_count(ch, 524, 511) - if n1 == 0 or n2 ~= 0 then - do_message(npc, ch, "Yeah right...") - else - do_message(npc, ch, "I can't help you with the party. But I see you have a fancy hat. I could change it into Santa's hat. Not much of a party, but it would get you going.") - v = do_choice(npc, ch, "Please do.", "No way! Fancy hats are classier.") - if v == 1 then - mana.chr_inv_change(ch, 524, -1, 511, 1) - end - end - - elseif v == 3 then - if mana.chr_money_change(ch, -100) then - do_message(npc, ch, string.format("Thank you for you patronage! You are left with %d GP.", mana.chr_money(ch))) - local g = tonumber(get_quest_var(ch, "001_donation")) - if not g then g = 0 end - g = g + 100 - mana.chr_set_quest(ch, "001_donation", g) - do_message(npc, ch, string.format("As of today, you have donated %d GP.", g)) - else - do_message(npc, ch, "I would feel bad taking money from someone that poor.") - end - - elseif v == 4 then - mana.being_say(npc, "As you wish...") - schedule_in(2, function() mana.being_say(npc, "One") end) - schedule_in(4, function() mana.being_say(npc, "Two") end) - schedule_in(6, function() mana.being_say(npc, "Three") end) - schedule_in(8, function() mana.being_say(npc, "Four") end) - schedule_in(10, function() mana.being_say(npc, "Five") end) - schedule_in(12, function() mana.being_say(npc, "Six") end) - schedule_in(14, function() mana.being_say(npc, "Seven") end) - schedule_in(16, function() mana.being_say(npc, "Eight") end) - schedule_in(18, function() mana.being_say(npc, "Nine") end) - schedule_in(20, function() mana.being_say(npc, "Ten") end) - - elseif v == 5 then - function printTable (t) - for k,v in pairs(t) do - print (k, ":", v) - end - end - local t1, t2, t3, t4, t5 = mana.test_tableget(); - print("---------------"); - print ("Table 1:"); - printTable (t1) - print ("Table 2:"); - printTable (t2) - print ("Table 3:"); - printTable (t3) - print ("Table 4:"); - printTable (t4) - print ("Table 5:"); - printTable (t5) - print("---------------"); - end - - do_message(npc, ch, "See you later!") -end - diff --git a/example/serverdata/scripts/npcs/emotemaker.lua b/example/serverdata/scripts/npcs/emotemaker.lua deleted file mode 100644 index 83d2f56f..00000000 --- a/example/serverdata/scripts/npcs/emotemaker.lua +++ /dev/null @@ -1,45 +0,0 @@ ----------------------------------------------------------- --- Emote use Function Sample -- ----------------------------------------------------------------------------------- --- Copyright 2009-2010 The Mana World Development Team -- --- -- --- This file is part of The Mana World. -- --- -- --- The Mana World is free software; you can redistribute it and/or modify it -- --- under the terms of the GNU General Public License as published by the Free -- --- Software Foundation; either version 2 of the License, or any later version. -- ----------------------------------------------------------------------------------- - -emo_count = 0 -emo_state = EMOTE_SURPRISE - -function emote_talk(npc, ch) - if emo_state == EMOTE_SURPRISE then - state = "confused" - elseif emo_state == EMOTE_SAD then - state = "sad" - elseif emo_state == EMOTE_HAPPY then - state = "happy" - end - do_message(npc, ch, string.format("The emotional palm seems %s.", state)) - v = do_choice(npc, ch, - "Stupid palm, you are ugly and everyone hates you!", - "You are such a nice palm, let me give you a hug.", - "Are you a cocos nucifera or a syagrus romanzoffiana?") - - if (v == 1) then - emo_state = EMOTE_SAD - elseif (v == 2) then - emo_state = EMOTE_HAPPY - elseif (v == 3) then - emo_state = EMOTE_SURPRISE - end -end - -function emote_update(npc) - emo_count = emo_count + 1 - if emo_count > 50 then - emo_count = 0 - mana.effect_create(emo_state, npc) - end -end diff --git a/example/serverdata/scripts/npcs/healer.lua b/example/serverdata/scripts/npcs/healer.lua deleted file mode 100644 index 88335c23..00000000 --- a/example/serverdata/scripts/npcs/healer.lua +++ /dev/null @@ -1,21 +0,0 @@ ----------------------------------------------------------- --- Healer Function Sample -- ----------------------------------------------------------------------------------- --- Copyright 2009-2010 The Mana World Development Team -- --- -- --- This file is part of The Mana World. -- --- -- --- The Mana World is free software; you can redistribute it and/or modify it -- --- under the terms of the GNU General Public License as published by the Free -- --- Software Foundation; either version 2 of the License, or any later version. -- ----------------------------------------------------------------------------------- - -function Healer(npc, ch) - do_message(npc, ch, "Do you need healing?") - local c = do_choice(npc, ch, "Heal me fully", "Heal 100 HP", "Don't heal me") - if c == 1 then - mana.being_heal(ch) - elseif c == 2 then - mana.being_heal(ch, 100) - end -end diff --git a/example/serverdata/scripts/npcs/merchant.lua b/example/serverdata/scripts/npcs/merchant.lua deleted file mode 100644 index 92eeea30..00000000 --- a/example/serverdata/scripts/npcs/merchant.lua +++ /dev/null @@ -1,114 +0,0 @@ ----------------------------------------------------------- --- Merchant Function Sample -- ----------------------------------------------------------------------------------- --- Copyright 2009-2010 The Mana World Development Team -- --- -- --- This file is part of The Mana World. -- --- -- --- The Mana World is free software; you can redistribute it and/or modify it -- --- under the terms of the GNU General Public License as published by the Free -- --- Software Foundation; either version 2 of the License, or any later version. -- ----------------------------------------------------------------------------------- - -function Merchant(npc, ch, buy_sell_table) - - local function say(message) - do_message(npc, ch, message) - end - - -- Important note: You can add two tables made of trinoms here when calling the - -- merchant function. E.g.: Merchant(npc, ch, buy_table, sell_table) - -- Even though, the function here will see only one table: - -- buy_sell_table[1] will corresponds to the first table (used to list - -- boughtable items, and buy_sell_table[2] listing sellable items. - - local rights = mana.chr_get_rights(ch); - - if (rights >= 128) then - mana.announce(mana.being_get_name(ch) .. " the big administrator was at my shop!", - mana.being_get_name(npc)) - say "Oh mighty server administrator, how can I avoid your wrath?" - elseif (rights >= 8) then - say "How can I be of assistance, sir gamemaster?" - elseif (rights >= 4) then - say "What feature would you like to debug, developer?" - elseif (rights >= 2) then - say "How can I assist you in your testing duties?" - elseif (rights >= 1) then - if mana.being_get_gender(ch) == GENDER_FEMALE then - say "What do you want, Madam?" - else - say "What do you want, Sir?" - end - else - say "...Aren't you supposed to be banned??" - end - - -- Constructing the choice list - local choice_table = {} - table.insert (choice_table, "To Buy...") - - if (buy_sell_table[2] == nil) then - table.insert (choice_table, "To sell stuff...") - else - table.insert (choice_table, "Can you make me a price for what I have?") - end - table.insert (choice_table, "Tell me about the objects on this map") - table.insert (choice_table, "Nevermind...") - - local v = do_choice(npc, ch, choice_table) - - --Debug and learning purpose - --for i,k in ipairs(choice_table) do print(i,k) end - -- The buy table first line content - --print (((buy_sell_table[1])[1])[1], ((buy_sell_table[1])[1])[2], ((buy_sell_table[1])[1])[3]) - -- The sell table first line content - --print (((buy_sell_table[2])[1])[1], ((buy_sell_table[2])[1])[2], ((buy_sell_table[2])[1])[3]) - - if v == 1 then - -- "To buy." - local buycase = mana.npc_trade(npc, ch, false, buy_sell_table[1]) - if buycase == 0 then - say "What do you want to buy?" - elseif buycase == 1 then - say "I've got no items to sell." - else - say "Hmm, something went wrong... Ask a scripter to fix the buying mode!" - end - - elseif v == 2 then - - if buy_sell_table[2] == nil then - -- "To sell stuff..." - local sellcase = mana.npc_trade(npc, ch, true) - if sellcase == 0 then - say "Ok, what do you want to sell?" - elseif sellcase == 1 then - say "I'm not interested by any of your items." - else - say "Hmm, something went wrong... Ask a scripter to fix this!" - end - else - -- "Can you make me a price for what I have?" - local sellcase = mana.npc_trade(npc, ch, true, buy_sell_table[2]) - if sellcase == 0 then - say "Here we go:" - elseif sellcase == 1 then - say "I'm not that interested in any of your items." - else - say "Hmm, something went wrong... Ask a scripter to fix me!" - end - end - - elseif v == 3 then - - local objects = mana.map_get_objects() - say("There are " .. #objects .. " objects on this map, their names are:") - for i=1,#objects do - say(tostring(i) .. ": " .. objects[i]:name()) - end - - end - - say "See you later!" -end diff --git a/example/serverdata/scripts/npcs/postman.lua b/example/serverdata/scripts/npcs/postman.lua deleted file mode 100644 index 712ea993..00000000 --- a/example/serverdata/scripts/npcs/postman.lua +++ /dev/null @@ -1,30 +0,0 @@ ----------------------------------------------------------- --- Postman Function Sample -- ----------------------------------------------------------------------------------- --- Copyright 2009-2010 The Mana World Development Team -- --- -- --- This file is part of The Mana World. -- --- -- --- The Mana World is free software; you can redistribute it and/or modify it -- --- under the terms of the GNU General Public License as published by the Free -- --- Software Foundation; either version 2 of the License, or any later version. -- ----------------------------------------------------------------------------------- - -function post_talk(npc, ch) - do_message(npc, ch, "Hello " .. mana.being_get_name(ch)) - local strength = mana.being_get_attribute(ch, ATTR_STRENGTH) - do_message(npc, ch, "You have " .. tostring(strength) .. " strength") - do_message(npc, ch, "What would you like to do?") - local answer = do_choice(npc, ch, "View Mail", "Send Mail", "Nothing") - if answer == 1 then - local sender, post = getpost(ch) - if sender == "" then - do_message(npc, ch, "No Post right now, sorry") - else - do_message(npc, ch, tostring(sender) .. " sent you " .. tostring(post)) - end - end - if answer == 2 then - do_post(npc, ch) - end -end diff --git a/example/serverdata/scripts/npcs/shaker.lua b/example/serverdata/scripts/npcs/shaker.lua deleted file mode 100644 index 9d7bafb7..00000000 --- a/example/serverdata/scripts/npcs/shaker.lua +++ /dev/null @@ -1,48 +0,0 @@ -----------------------------------------------------------------------------------
--- Copyright 2009-2010 The Mana World Development Team --
--- --
--- This file is part of The Mana World. --
--- --
--- The Mana World is free software; you can redistribute it and/or modify it --
--- under the terms of the GNU General Public License as published by the Free --
--- Software Foundation; either version 2 of the License, or any later version. --
-----------------------------------------------------------------------------------
-
-shake_count = 0
-
-function shaker_update(npc)
- shake_count = shake_count + 1
- if shake_count > 20 then
- shake_count = 0
-
- center_x = mana.posX(npc)
- center_y = mana.posY(npc)
- tremor(center_x, center_y, 300)
-
- end
-end
-
--- function which causes a screen shake effect for all players near a
--- certain point with an intensity and direction relative to said point
-function square(x)
- return x * x
-end
-
-function tremor (center_x, center_y, intensity)
- for dummy, object in ipairs(mana.get_beings_in_circle(center_x, center_y, intensity)) do
- if mana.being_type(object) == TYPE_CHARACTER then
- object_x = mana.posX(object)
- object_y = mana.posY(object)
- dist_x = object_x - center_x
- dist_y = object_y - center_y
- dist = math.sqrt(square(dist_x) + square(dist_y))
- intensity_local = intensity - dist
- intensity_x = (intensity - dist) * (dist_x / dist) / 5
- intensity_y = (intensity - dist) * (dist_y / dist) / 5
- mana.chr_shake_screen(object, intensity_x, intensity_y)
- end
- end
-end
-
-
-
|