diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2010-12-30 00:38:15 +0100 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2010-12-30 00:38:15 +0100 |
commit | 12926decd2af8d0b34b632b2d0b55fc9aa134291 (patch) | |
tree | fc40af9ccc156b841ac2c654cf2a7e03d0c843ac /example/serverdata/scripts | |
parent | 64b832b8d3aac6dc55103f751fcae6b4dbb423ca (diff) | |
download | manaserv-12926decd2af8d0b34b632b2d0b55fc9aa134291.tar.gz manaserv-12926decd2af8d0b34b632b2d0b55fc9aa134291.tar.bz2 manaserv-12926decd2af8d0b34b632b2d0b55fc9aa134291.tar.xz manaserv-12926decd2af8d0b34b632b2d0b55fc9aa134291.zip |
Added new example files needed to start a more complete feature-showing map.
I also replaced certain files with newer version, just as the items.xml file.
And I started to split test npcs from the tmwserv repository into reusable
pieces.
Big but trivial.
Part of the Mana-Mantis issue: #231.
Diffstat (limited to 'example/serverdata/scripts')
-rw-r--r-- | example/serverdata/scripts/global_events.lua | 41 | ||||
-rw-r--r-- | example/serverdata/scripts/items/candy.lua | 17 | ||||
-rw-r--r-- | example/serverdata/scripts/monster/testmonster.lua | 26 | ||||
-rw-r--r-- | example/serverdata/scripts/npcs/banker.lua | 74 | ||||
-rw-r--r-- | example/serverdata/scripts/npcs/barber.lua | 141 | ||||
-rw-r--r-- | example/serverdata/scripts/npcs/debugger.lua | 101 | ||||
-rw-r--r-- | example/serverdata/scripts/npcs/emotemaker.lua | 46 | ||||
-rw-r--r-- | example/serverdata/scripts/npcs/healer.lua | 23 | ||||
-rw-r--r-- | example/serverdata/scripts/npcs/postman.lua | 31 | ||||
-rw-r--r-- | example/serverdata/scripts/npcs/seller.lua | 73 | ||||
-rw-r--r-- | example/serverdata/scripts/status/jump.lua | 53 | ||||
-rw-r--r-- | example/serverdata/scripts/status/plague.lua | 28 |
12 files changed, 644 insertions, 10 deletions
diff --git a/example/serverdata/scripts/global_events.lua b/example/serverdata/scripts/global_events.lua index 51047e90..90b096cd 100644 --- a/example/serverdata/scripts/global_events.lua +++ b/example/serverdata/scripts/global_events.lua @@ -18,40 +18,61 @@ ---------------------------------------------------------------------------------- - --- This function is called when the hit points of a character reach zero. +-- This function is called when the hit points of a character reach zero. function on_chr_death(ch) + mana.being_say(ch, "Noooooo!!!") end --- This function is called when the player clicks on the “OK” button after --- the death message appeared. It should be used to implement the respawn --- mechanic (for example: warp the character to the respawn location and --- bring HP above zero in some way) +-- This function is called when the player clicks on the �OK� button after +-- the death message appeared. It should be used to implement the respawn +-- mechanic (for example: warp the character to the respawn location and +-- bring HP above zero in some way) function on_chr_death_accept(ch) + mana.being_heal(ch) -- restores to full hp + -- mana.being_heal(ch, 1) --restores 1 hp (in case you want to be less nice) + -- mana.chr_warp(ch, 1, 2000, 2000) --warp the character to the respawn location end -- This function is called after chr_death_accept. The difference is that -- it is called in the context of the map the character is spawned on after --- the respawn logic has happened. +-- the respawn logic has happened. function on_chr_respawn(ch) - mana.being_heal() + -- calls the local_respawn_function of the map the character respawned + -- on when the script of the map has one + if local_respawn_function ~= nil then + local_respawn_function(ch) + end end -- This function is called when a new character enters the world for the -- first time. This can, for example, be used to give starting equipment --- to the character and/or initialize a tutorial quest. +-- to the character and/or initialize a tutorial quest. function on_chr_birth(ch) + -- this message is shown on first login. + mana.chatmessage(0, ch, "And so your adventure begins...") end -- This function is called when a character logs into the game. This can, -- for example, be utilized for a message-of-the-day or for various --- handlings of offline processing mechanics. +-- handlings of offline processing mechanics. function on_chr_login(ch) + mana.chatmessage(0, ch, "Welcome to Manasource") end -- This function is called when a character is disconnected. This could -- be useful for various handling of offline processing mechanics. function on_chr_logout(ch) + -- notifies nearby players of logout + local around = mana.get_beings_in_circle( + posX(ch), + posY(ch), + 1000) + local msg = mana.being_get_name(ch).." left the game." + for b in pairs(around) do + if mana.being_type(b) == TYPE_CHARACTER then + mana.chatmessage(0, b, msg) + end + end end diff --git a/example/serverdata/scripts/items/candy.lua b/example/serverdata/scripts/items/candy.lua new file mode 100644 index 00000000..a740ce6a --- /dev/null +++ b/example/serverdata/scripts/items/candy.lua @@ -0,0 +1,17 @@ +------------------------------------------------------------- +-- Example use script. Makes the player character say -- +-- "*munch*munch*munch*" when using this item. -- +-- The HP regeneration effect is handled separately based -- +-- on the heal value in items.xml -- +---------------------------------------------------------------------------------- +-- 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. -- +---------------------------------------------------------------------------------- +function use(user) + mana.being_say(user, "*munch*munch*munch*") +end diff --git a/example/serverdata/scripts/monster/testmonster.lua b/example/serverdata/scripts/monster/testmonster.lua new file mode 100644 index 00000000..9938943b --- /dev/null +++ b/example/serverdata/scripts/monster/testmonster.lua @@ -0,0 +1,26 @@ +---------------------------------------------------------------------------------- +-- 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. -- +---------------------------------------------------------------------------------- + +function update(mob) + local r = math.random(0, 200); + if r == 0 then + mana.being_say(mob, "Roar! I am a boss") + end +end + +function strike(mob, victim, hit) + if hit > 0 then + mana.being_say(mob, "Take this! "..hit.." damage!") + mana.being_say(victim, "Oh Noez!") + else + mana.being_say(mob, "Oh no, my attack missed!") + mana.being_say(victim, "Whew...") + end +end diff --git a/example/serverdata/scripts/npcs/banker.lua b/example/serverdata/scripts/npcs/banker.lua new file mode 100644 index 00000000..79d6af6d --- /dev/null +++ b/example/serverdata/scripts/npcs/banker.lua @@ -0,0 +1,74 @@ +---------------------------------------------------------- +-- 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) + do_message(npc, ch, "Welcome to the bank!") + 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!") + do_npc_close(npc, ch) +end diff --git a/example/serverdata/scripts/npcs/barber.lua b/example/serverdata/scripts/npcs/barber.lua new file mode 100644 index 00000000..24ad8c9b --- /dev/null +++ b/example/serverdata/scripts/npcs/barber.lua @@ -0,0 +1,141 @@ +---------------------------------------------------------- +-- 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 = {"Brunette", "Green", "Dark red", "Light purple", "Gray", "Blonde", + "Teal", "Light red", "Blue", "Dark purple", "Black"} + +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 -- Since we haven't shown any windows, we can safely + -- return without a do_npc_close + 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, "Supprise 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, "Supprise 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!") + do_npc_close(npc, ch) +end diff --git a/example/serverdata/scripts/npcs/debugger.lua b/example/serverdata/scripts/npcs/debugger.lua new file mode 100644 index 00000000..6bb86d0a --- /dev/null +++ b/example/serverdata/scripts/npcs/debugger.lua @@ -0,0 +1,101 @@ +---------------------------------------------------------- +-- 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!") + do_npc_close(npc, ch) +end + diff --git a/example/serverdata/scripts/npcs/emotemaker.lua b/example/serverdata/scripts/npcs/emotemaker.lua new file mode 100644 index 00000000..2e68aa2c --- /dev/null +++ b/example/serverdata/scripts/npcs/emotemaker.lua @@ -0,0 +1,46 @@ +---------------------------------------------------------- +-- 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 + do_npc_close(npc, ch) +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 new file mode 100644 index 00000000..96d29111 --- /dev/null +++ b/example/serverdata/scripts/npcs/healer.lua @@ -0,0 +1,23 @@ +---------------------------------------------------------- +-- 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 + + do_npc_close(npc, ch) +end diff --git a/example/serverdata/scripts/npcs/postman.lua b/example/serverdata/scripts/npcs/postman.lua new file mode 100644 index 00000000..68546bf8 --- /dev/null +++ b/example/serverdata/scripts/npcs/postman.lua @@ -0,0 +1,31 @@ +---------------------------------------------------------- +-- 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 + do_npc_close(npc, ch) +end diff --git a/example/serverdata/scripts/npcs/seller.lua b/example/serverdata/scripts/npcs/seller.lua new file mode 100644 index 00000000..c809f3e2 --- /dev/null +++ b/example/serverdata/scripts/npcs/seller.lua @@ -0,0 +1,73 @@ +---------------------------------------------------------- +-- 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 Seller(npc, ch) + do_message(npc, ch, "Hello! What can I provide you today?") + 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, "To buy...", + "To sell stuff...", + "Can you make me a price for what I have?") + if v == 1 then + -- "To buy." + local buycase = mana.npc_trade(npc, ch, false, { {1, 10, 20}, {2, 10, 30}, {3, 10, 50} }) + if buycase == 0 then + do_message(npc, ch, "What do you want to buy?") + elseif buycase == 1 then + do_message(npc, ch, "I've got no items to sell.") + else + do_message(npc, ch, "Hmm, something went wrong... Ask a scripter to fix the buying mode!") + end + + elseif v == 2 then + + -- "To sell stuff..." + local sellcase = mana.npc_trade(npc, ch, true) + if sellcase == 0 then + do_message(npc, ch, "Ok, what do you want to sell?") + elseif sellcase == 1 then + do_message(npc, ch, "I'm not interested by any of your items.") + else + do_message(npc, ch, "Hmm, something went wrong... Ask a scripter to fix this!") + end + + elseif v == 3 then + + -- "Can you make me a price for what I have?" + local sellcase = mana.npc_trade(npc, ch, true, { {4, 10, 20}, {5, 10, 30}, {6, 10, 200}, {7, 10, 300} }) + if sellcase == 0 then + do_message(npc, ch, "Here we go:") + elseif sellcase == 1 then + do_message(npc, ch, "I'm not that interested in any of your items.") + else + do_message(npc, ch, "Hmm, something went wrong... Ask a scripter to fix me!") + end + + end + do_message(npc, ch, "See you later!") + do_npc_close(npc, ch) +end + diff --git a/example/serverdata/scripts/status/jump.lua b/example/serverdata/scripts/status/jump.lua new file mode 100644 index 00000000..3410747a --- /dev/null +++ b/example/serverdata/scripts/status/jump.lua @@ -0,0 +1,53 @@ +------------------------------------------------------------- +-- This status jumps from being to being -- +-- Thats all it does. -- +---------------------------------------------------------------------------------- +-- 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. -- +---------------------------------------------------------------------------------- + + +function tick(target, ticknumber) + if (ticknumber % 10 == 0) then + mana.being_say(target, "I have the jumping bug!") + end + + if (mana.being_get_status_time(target, 2) < 2000) then + mana.being_set_status_time(target, 2, 6000) + end + + if (ticknumber % 50 ~= 0) then return end + + local victims = mana.get_beings_in_circle(mana.posX(target), mana.posY(target), 64) + local count = #victims + + if i == 0 then return end + + local i + local remaining = 1000 + local victim = nil + + repeat + remaining = remaining - 1 + i = math.random(count) + victim = victims[i] + if (victim == target) then + victim = nil + i = -1 + else + i = mana.being_type(victim) + end + until (i == TYPE_MONSTER or i == TYPE_CHARACTER or remaining == 0) + + if (victim == nil) then return end + + mana.being_remove_status(target, 2) + + mana.being_apply_status(victim, 2, 6000) + mana.being_say(victim, "Now I have the jumping bug") +end diff --git a/example/serverdata/scripts/status/plague.lua b/example/serverdata/scripts/status/plague.lua new file mode 100644 index 00000000..5f98268e --- /dev/null +++ b/example/serverdata/scripts/status/plague.lua @@ -0,0 +1,28 @@ +------------------------------------------------------------- +-- This when applied to a being will spread from one being -- +-- to another -- +-- Thats all it does. -- +---------------------------------------------------------------------------------- +-- 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. -- +---------------------------------------------------------------------------------- + +function tick(target, ticknumber) + if (ticknumber % 10 == 0) then + mana.being_say(target, "I have the plague! :( = " .. ticknumber) + end + local victims = mana.get_beings_in_circle(mana.posX(target), mana.posY(target), 64) + local i = 1 + while (victims[i]) do + if (mana.being_has_status(victims[i], 1) == false) then + mana.being_apply_status(victims[i], 1, 6000) + mana.being_say(victims[i], "I don't feel so good") + end + i = i + 1 + end +end |