summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/items.xsd55
-rw-r--r--data/maps.xml41
-rw-r--r--data/scripts/libs/libtmw-constants.lua66
-rw-r--r--data/scripts/libs/libtmw.lua391
-rw-r--r--data/scripts/libs/npclib.lua95
-rw-r--r--data/scripts/test.lua261
6 files changed, 0 insertions, 909 deletions
diff --git a/data/items.xsd b/data/items.xsd
deleted file mode 100644
index 2517bbf0..00000000
--- a/data/items.xsd
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
-
- <!-- ITEMS LIST FILE SCHEMA -->
-
- <xsd:element name="items">
- <xsd:complexType>
- <xsd:sequence>
-
- <xsd:element name="item" minOccurs="0" maxOccurs="unbounded">
- <xsd:complexType>
- <xsd:simpleContent>
- <xsd:extension base="xsd:positiveInteger">
- <!-- General -->
- <xsd:attribute name="id" type="xsd:positiveInteger" />
- <xsd:attribute name="type" type="xsd:integer" />
- <xsd:attribute name="weight" type="xsd:integer" />
- <xsd:attribute name="value" type="xsd:integer" />
- <xsd:attribute name="max_per_slot" type="xsd:positiveInteger" />
- <xsd:attribute name="script_name" type="xsd:string" />
- <!-- Modifiers -->
- <xsd:attribute name="element" type="xsd:integer" />
- <xsd:attribute name="lifetime" type="xsd:positiveInteger" />
- <!-- Raw Statistics -->
- <xsd:attribute name="strength" type="xsd:integer" />
- <xsd:attribute name="agility" type="xsd:integer" />
- <xsd:attribute name="vitality" type="xsd:integer" />
- <xsd:attribute name="intelligence" type="xsd:integer" />
- <xsd:attribute name="dexterity" type="xsd:integer" />
- <xsd:attribute name="luck" type="xsd:integer" />
- <!-- Computed Statistics -->
- <xsd:attribute name="heat" type="xsd:integer" />
- <xsd:attribute name="attack" type="xsd:integer" />
- <xsd:attribute name="defence" type="xsd:integer" />
- <xsd:attribute name="magic" type="xsd:integer" />
- <xsd:attribute name="accuracy" type="xsd:integer" />
- <xsd:attribute name="speed" type="xsd:integer" />
- <!-- Main Values -->
- <xsd:attribute name="hp" type="xsd:integer" />
- <xsd:attribute name="mp" type="xsd:integer" />
- <!-- Equipment -->
- <xsd:attribute name="range" type="xsd:integer" />
- <xsd:attribute name="weapon_type" type="xsd:integer" />
- <!-- Status Effects Addition -->
- <xsd:attribute name="status_effect" type="xsd:integer" />
- </xsd:extension>
- </xsd:simpleContent>
- </xsd:complexType>
- </xsd:element>
-
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
-
-</xsd:schema>
diff --git a/data/maps.xml b/data/maps.xml
deleted file mode 100644
index 65887a87..00000000
--- a/data/maps.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0"?>
-<maps>
- <map id="1" name="new_1-1"/>
- <map id="2" name="new_2-1"/>
- <map id="3" name="new_3-1"/>
- <map id="4" name="new_4-1"/>
- <map id="5" name="new_5-1"/>
- <map id="6" name="new_6-1"/>
- <map id="7" name="new_7-1"/>
- <map id="8" name="new_8-1"/>
- <map id="9" name="new_9-1"/>
- <map id="10" name="new_10-1"/>
- <map id="11" name="new_11-1"/>
- <map id="12" name="new_12-1"/>
- <map id="13" name="new_13-1"/>
- <map id="14" name="new_14-1"/>
- <map id="15" name="new_15-1"/>
- <map id="16" name="new_16-1"/>
- <map id="17" name="new_17-1"/>
- <map id="18" name="new_18-1"/>
- <map id="19" name="new_19-1"/>
- <map id="20" name="new_20-1"/>
- <map id="21" name="new_21-1"/>
- <map id="22" name="new_22-1"/>
- <map id="23" name="new_23-1"/>
- <map id="24" name="new_24-1"/>
- <map id="25" name="new_25-1"/>
- <map id="26" name="new_26-1"/>
- <map id="27" name="new_27-1"/>
- <map id="28" name="new_28-1"/>
- <map id="29" name="new_29-1"/>
- <map id="30" name="new_30-1"/>
- <map id="31" name="new_31-1"/>
- <map id="32" name="new_32-1"/>
- <map id="33" name="new_33-1"/>
- <map id="34" name="new_34-1"/>
- <map id="35" name="new_35-1"/>
- <map id="36" name="new_36-1"/>
- <map id="37" name="new_37-1"/>
- <map id="38" name="new_38-1"/>
-</maps>
diff --git a/data/scripts/libs/libtmw-constants.lua b/data/scripts/libs/libtmw-constants.lua
deleted file mode 100644
index 36b27f7b..00000000
--- a/data/scripts/libs/libtmw-constants.lua
+++ /dev/null
@@ -1,66 +0,0 @@
--------------------------------------------------------------
--- TMW Support Library Constants --
--- --
--- Some useful numeric values for use by other scripts. --
--- --
-----------------------------------------------------------------------------------
--- 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. --
-----------------------------------------------------------------------------------
-
-DAMAGE_PHYSICAL = 0
-DAMAGE_MAGICAL = 1
-DAMAGE_OTHER = 2
-
-ELEMENT_NEUTRAL = 0
-ELEMENT_FIRE = 1
-ELEMENT_WATER = 2
-ELEMENT_EARTH = 3
-ELEMENT_AIR = 4
-ELEMENT_LIGHTNING = 5
-ELEMENT_METAL = 6
-ELEMENT_WOOD = 7
-ELEMENT_ICE = 8
-
-ATTR_PHY_ATK_MIN = 0
-ATTR_PHY_ATK_DELTA = 1
-ATTR_MAG_ATK = 2
-ATTR_PHY_RES = 3
-ATTR_MAG_RES = 4
-ATTR_EVADE = 5
-ATTR_HIT = 6
-ATTR_HP = 7
-ATTR_HP_REGEN = 8
-ELEM_NEUTRAL = 9
-ELEM_FIRE = 10
-ELEM_WATER = 11
-ELEM_EARTH = 12
-ELEM_AIR = 13
-ELEM_SACRED = 14
-ELEM_DEATH = 15
-ATTR_STRENGTH = 16
-ATTR_AGILITY = 17
-ATTR_DEXTERITY = 18
-ATTR_VITALITY = 19
-ATTR_INTELLIGENCE = 20
-ATTR_WILLPOWER = 21
-SKILL_WEAPON_NONE = 22
-SKILL_WEAPON_KNIFE = 23
-SKILL_WEAPON_SWORD = 24
-SKILL_WEAPON_POLEARM = 25
-SKILL_WEAPON_STAFF = 26
-SKILL_WEAPON_WHIP = 27
-SKILL_WEAPON_BOW = 28
-SKILL_WEAPON_SHOOTING = 29
-SKILL_WEAPON_MACE = 30
-SKILL_WEAPON_AXE = 31
-SKILL_WEAPON_THROWN = 32
-
-TILESIZE = 32
-HOURS = 3600
-MINUTES = 60 \ No newline at end of file
diff --git a/data/scripts/libs/libtmw.lua b/data/scripts/libs/libtmw.lua
deleted file mode 100644
index 4505d153..00000000
--- a/data/scripts/libs/libtmw.lua
+++ /dev/null
@@ -1,391 +0,0 @@
--------------------------------------------------------------
--- TMW Support Library --
--- --
--- Functions which are called by the game engine and --
--- helper functions useful for writing other scripts. --
--- --
-----------------------------------------------------------------------------------
--- 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. --
-----------------------------------------------------------------------------------
-
-dofile("data/scripts/libs/libtmw-constants.lua")
-
-
--- Table that associates to each NPC pointer the handler function that is
--- called when a player starts talking to an NPC.
-local npc_talk_functs = {}
-local npc_update_functs = {}
-
--- Table that associates to each Character pointer its state with respect to
--- NPCs (only one at a time). A state is an array with four fields:
--- . 1: pointer to the NPC the player is currently talking to.
--- . 2: coroutine running the NPC handler.
--- . 3: next event the NPC expects from the server.
--- (1 = npc_next, 2 = npc_choose, 3 = quest_reply, 4 = 1+3)
--- . 4: countdown (in minutes) before the state is deleted.
--- . 5: name of the expected quest variable. (optional)
-local states = {}
-
--- Array containing the function registered by atinit.
-local init_fun = {}
-
--- Tick timer used during update to clean obsolete states.
-local timer
-
--- Creates an NPC and associates the given handler.
--- Note: Cannot be called until map initialization has started.
-function create_npc(name, id, x, y, talkfunct, updatefunct)
- local npc = tmw.npc_create(name, id, x, y)
- if talkfunct then npc_talk_functs[npc] = talkfunct end
- if updatefunct then npc_update_functs[npc] = updatefunct end
- return npc
-end
-
--- Waits for the player to acknowledge the previous message, if any.
-function do_wait()
- coroutine.yield(0)
-end
-
--- Sends an npc message to a player.
--- Note: Does not wait for the player to acknowledge the message.
-function do_message(npc, ch, msg)
- -- Wait for the arrival of a pending acknowledgment, if any.
- coroutine.yield(0)
- tmw.npc_message(npc, ch, msg)
- -- An acknowledgment is pending, but do not wait for its arrival.
- coroutine.yield(1)
-end
-
--- Sends an NPC question to a player and waits for its answer.
-function do_choice(npc, ch, ...)
- -- Wait for the arrival of a pending acknowledgment, if any.
- coroutine.yield(0)
- tmw.npc_choice(npc, ch, ...)
- -- Wait for player choice.
- return coroutine.yield(2)
-end
-
--- Sends an NPC request to send letter to a player and waits for them to
--- send the letter.
-function do_post(npc, ch)
- coroutine.yield(0)
- tmw.npc_post(npc, ch)
- return coroutine.yield(1)
-end
-
--- Gets the value of a quest variable.
--- Calling this function while an acknowledment is pending is desirable, so
--- that lag cannot be perceived by the player.
-function get_quest_var(ch, name)
- -- Query the server and return immediatly if a value is available.
- local value = tmw.chr_get_quest(ch, name)
- if value then return value end
- -- Wait for database reply.
- return coroutine.yield(3, name)
-end
-
--- Gets the post for a user.
-function getpost(ch)
- tmw.chr_get_post(ch)
- return coroutine.yield(3)
-end
-
--- Processes as much of an NPC handler as possible.
-local function process_npc(w, ...)
- local co = w[2]
- local pending = (w[3] == 4)
- local first = true
- while true do
- local b, v, u
- if first then
- -- First time, resume with the arguments the coroutine was waiting for.
- b, v, u = coroutine.resume(co, ...)
- first = false
- else
- -- Otherwise, simply resume.
- b, v, u = coroutine.resume(co)
- end
- if not b or not v then
- -- Either there was an error, or the handler just finished its work.
- return
- end
- if v == 2 then
- -- The coroutine needs a user choice from the server, so wait for it.
- w[3] = 2
- break
- end
- if v == 3 then
- -- The coroutine needs the value of a quest variable from the server.
- w[5] = u
- if pending then
- -- The coroutine has also sent a message to the user, so do not
- -- forget about it, as it would flood the user with new messages.
- w[3] = 4
- else
- w[3] = 3
- end
- break
- end
- if pending then
- -- The coroutine is about to interact with the user. But the previous
- -- action has not been acknowledged by the user yet, so wait for it.
- w[3] = 1
- break
- end
- if v == 1 then
- -- A message has just been sent. But the coroutine can keep going in case
- -- there is still some work to do while waiting for user acknowledgment.
- pending = true
- end
- end
- -- Restore the countdown, as there was some activity.
- w[4] = 5
- return true
-end
-
--- Called by the game whenever a player starts talking to an NPC.
--- Creates a coroutine based on the registered NPC handler.
-function npc_start(npc, ch)
- states[ch] = nil
- local h = npc_talk_functs[npc]
- if not h then return end
- local w = { npc, coroutine.create(h) }
- if process_npc(w, npc, ch) then
- states[ch] = w
- if not timer then
- timer = 600
- end
- end
-end
-
--- Called by the game whenever a player keeps talking to an NPC.
--- Checks that the NPC expects it, and processes the respective coroutine.
-function npc_next(npc, ch)
- local w = states[ch]
- if w then
- local w3 = w[3]
- if w3 == 4 then
- w[3] = 3
- return
- end
- if w3 == 1 and process_npc(w) then
- return
- end
- end
- states[ch] = nil
-end
-
--- Called by the game whenever a player selects a particular reply.
--- Checks that the NPC expects it, and processes the respective coroutine.
-function npc_choose(npc, ch, u)
- local w = states[ch]
- if not (w and w[1] == npc and w[3] == 2 and process_npc(w, u)) then
- states[ch] = nil
- end
-end
-
--- Called by the game when a player sends a letter.
-function npc_post(npc, ch, sender, letter)
- local w = states[ch]
- if not (w and w[1] == npc and w[3] == 1 and process_npc(w, sender, letter)) then
- states[ch] = nil
- end
-end
-
--- Called by the game whenever the value of a quest variable is known.
--- Checks that the NPC expects it, and processes the respective coroutine.
--- Note: the check for NPC correctness is missing, but it should never matter.
-function quest_reply(ch, name, value)
- local w = states[ch]
- if w then
- local w3 = w[3]
- if (w3 == 3 or w3 == 4) and w[5] == name then
- w[5] = nil
- if process_npc(w, value) then
- return
- end
- end
- end
- states[ch] = nil
-end
-
-function post_reply(ch, sender, letter)
- local w = states[ch]
- if w then
- local w3 = w[3]
- if (w3 == 3 or w3 == 4) then
- if process_npc(w, sender, letter) then
- return
- end
- end
- end
- states[ch] = nil
-end
-
--- Called by the game every tick for each NPC.
-function npc_update(npc)
- local h = npc_update_functs[npc];
- if h then h(npc) end;
-end
-
--- Called by the game every tick.
--- Checks for scheduled function calls
--- Cleans obsolete connections.
-function update()
- -- check the scheduler
- check_schedule()
-
- -- Run every minute only, in order not to overload the server.
- if not timer then return end
- timer = timer - 1
- if timer ~= 0 then return end
- -- Free connections that have been inactive for 3-4 minutes.
- for k, w in pairs(states) do
- local t = w[4] - 1
- if t == 0 then
- states[k] = nil
- else
- w[4] = t
- end
- end
- -- Restart timer if there are still some pending states.
- if next(states) then
- timer = 600
- else
- timer = nil
- end
-end
-
--- Registers a function so that is is executed during map initialization.
-function atinit(f)
- init_fun[#init_fun + 1] = f
-end
-
--- Called by the game for creating NPCs embedded into maps.
--- Delays the creation until map initialization is performed.
--- Note: Assumes that the "npc_handler" global field contains the NPC handler.
-function create_npc_delayed(name, id, x, y)
- -- Bind the name to a local variable first, as it will be reused.
- local h = npc_handler
- atinit(function() create_npc(name, id, x, y, h, nil) end)
- npc_handler = nil
-end
-
--- Called during map initialization.
--- Executes all the functions registered by atinit.
-function initialize()
- for i,f in ipairs(init_fun) do
- f()
- end
- init_fun = nil
-end
-
-
--- SCHEDULER
-
--- Table of scheduled jobs. A job is an array with 3 elements:
--- 0: the UNIX timestamp when it is executed
--- 1: the function which is executed
--- 2: nil when it is a one-time job. Repetition interval is seconds when it is
--- a repeated job.
-local scheduler_jobs = {}
-
--- compare function used to sort the scheduler_jobs table.
--- the jobs which come first are at the end of the table.
-local function job_cmp(job1, job2)
- return (job1[0] > job2[0])
-end
-
--- checks for jobs which have to be executed, executes them and reschedules
--- them when they are repeated jobs.
-function check_schedule()
- if #scheduler_jobs==0 then return end
- while os.time() > scheduler_jobs[#scheduler_jobs][0] do
- -- retreive the job and remove it from the schedule
- job = scheduler_jobs[#scheduler_jobs]
- table.remove(scheduler_jobs)
- -- reschedule the job when it is a repeated job
- if job[2] then
- schedule_every(job[2], job[1])
- end
- -- execute the job
- job[1]()
- end
-end
-
--- schedules a function call to be executed once in n seconds
-function schedule_in(seconds, funct)
- local job = {}
- job[0] = os.time() + seconds
- job[1] = funct
- job[2] = nil
- table.insert(scheduler_jobs, job)
- table.sort(scheduler_jobs, job_cmp)
-end
-
--- schedules a function call to be executed at regular intervals of n seconds
-function schedule_every(seconds, funct)
- local job = {}
- job[0] = os.time() + seconds
- job[1] = funct
- job[2] = seconds
- table.insert(scheduler_jobs, job)
- table.sort(scheduler_jobs, job_cmp)
-end
-
-
--- DEATH NOTIFICATIONS
-local ondeath_functs = {}
-
--- requests the gameserver to notify the script engine when the being
--- dies and adds a script function to be executed in this case.
-function on_death(being, funct)
- if ondeath_functs[being] == nil then
- ondeath_functs[being] = {}
- end
- table.insert(ondeath_functs[being], funct)
- tmw.note_on_death(being)
-end
-
--- called by the engine when a being with dies for which a death
--- notification has been requested
-function death_notification(being)
- if type(ondeath_functs[being]) == "table" then
- for i,funct in pairs(ondeath_functs[being]) do
- funct()
- end
- ondeath_functs[being] = nil
- end
-end
-
-
--- Below are some convenience methods added to the engine API
-
-tmw.chr_money_change = function(ch, amount)
- return tmw.chr_inv_change(ch, 0, amount)
-end
-
-tmw.chr_money = function(ch)
- return tmw.chr_inv_count(ch, 0)
-end
-
-
-
-function cast(ch, arg)
- if arg == 1 then
- tmw.being_say(ch, "Kaaame...Haaame... HAAAAAA!")
- end
- if arg == 2 then
- tmw.being_say(ch, "HAA-DOKEN!")
- end
- if arg == 3 then
- tmw.being_say(ch, "Sonic BOOM")
- end
-
-end
diff --git a/data/scripts/libs/npclib.lua b/data/scripts/libs/npclib.lua
deleted file mode 100644
index e85ddc56..00000000
--- a/data/scripts/libs/npclib.lua
+++ /dev/null
@@ -1,95 +0,0 @@
-----------------------------------------------------------
--- Library for commonly used NPC scripts --
--- --
--- --
--- Any NPC update function or talk function which could --
--- be used for NPCs on more than one map should be --
--- placed here. --
--- --
-----------------------------------------------------------------------------------
--- 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. --
-----------------------------------------------------------------------------------
-
-module("npclib", package.seeall);
-
-
--- Update function walkaround_small
--- makes the NPC walk around in a 64x64 pixel square around its start location.
--- Useful for NPCs which are supposed to stay on a specific spot but
--- move a bit from time to time.
-
-local wasmall_timer = {}
-local wasmall_startx = {}
-local wasmall_starty = {}
-
-function walkaround_small(npc)
- if not wasmall_timer[npc] then
- wasmall_timer[npc] = 1
- wasmall_startx[npc] = tmw.posX(npc)
- wasmall_starty[npc] = tmw.posY(npc)
- end
-
- wasmall_timer[npc] = wasmall_timer[npc] + 1
-
- if wasmall_timer[npc] == 100 then
- wasmall_timer[npc] = math.random(1, 10)
- local x = math.random(-32, 32) + wasmall_startx[npc]
- local y = math.random(-32, 32) + wasmall_starty[npc]
- tmw.being_walk(npc, x, y, 500)
- end
-end
-
-
--- Update function walkaround_wide
--- makes the NPC walk around in a 256x256 pixel square around its start
--- location. Useful for NPCs which are supposed to be found near a specific
--- location but not nailed to the floor.
-
-local wawide_timer = {}
-local wawide_startx = {}
-local wawide_starty = {}
-
-function walkaround_wide(npc)
- if not wawide_timer[npc] then
- wawide_timer[npc] = 1
- wawide_startx[npc] = tmw.posX(npc)
- wawide_starty[npc] = tmw.posY(npc)
- end
-
- wawide_timer[npc] = wawide_timer[npc] + 1
-
- if wawide_timer[npc] == 50 then
- wawide_timer[npc] = math.random(1, 10)
- local x = math.random(-128, 128) + wawide_startx[npc]
- local y = math.random(-128, 128) + wawide_starty[npc]
- tmw.being_walk(npc, x, y, 500)
- end
-end
-
-
--- Update function walkaround_map
--- makes the NPC wander around the whole map. Useful when the players are
--- supposed to search a bit for the NPC.
-
-local wam_timer = {}
-
-function walkaround_map(npc)
- if not wam_timer[npc] then
- wam_timer[npc] = 1
- end
-
- wam_timer[npc] = wam_timer[npc] + 1
-
- if wam_timer[npc] == 50 then
- wam_timer[npc] = math.random(1, 10)
- local x = math.random(-128, 128) + tmw.posX(npc)
- local y = math.random(-128, 128) + tmw.posY(npc)
- tmw.being_walk(npc, x, y, 500)
- end
-end \ No newline at end of file
diff --git a/data/scripts/test.lua b/data/scripts/test.lua
deleted file mode 100644
index 1f7e12a6..00000000
--- a/data/scripts/test.lua
+++ /dev/null
@@ -1,261 +0,0 @@
-----------------------------------------------------------
--- Test Scripts --
--- --
--- Provisorical NPC scripts currently included on map --
--- new_1-1.tmx for demonstrating and testing variouse --
--- features of the scripting engine. --
--- --
-----------------------------------------------------------------------------------
--- 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. --
-----------------------------------------------------------------------------------
-
-require "data/scripts/libs/npclib"
-
-atinit(function()
- create_npc("Test NPC", 200, 50 * TILESIZE + 16, 19 * TILESIZE + 16, npc1_talk, npclib.walkaround_small)
- create_npc("Teleporter", 201, 51 * TILESIZE + 16, 25 * TILESIZE + 16, npc4_talk, npclib.walkaround_wide)
- create_npc("Scorpion Tamer", 126, 45 * TILESIZE + 16, 25 * TILESIZE + 16, npc5_talk, nil)
- create_npc("Guard", 122, 58 * TILESIZE + 16, 15 * TILESIZE + 16, npc6_talk, npc6_update)
- create_npc("Fire Demon", 202, 58 * TILESIZE + 16, 35 * TILESIZE + 16, firedemon_talk, firedemon_update)
- create_npc("Post Box", 158, 45 * TILESIZE + 16, 22 * TILESIZE + 16, post_talk)
- create_npc("Fireworker", 158, 43 * TILESIZE, 23 * TILESIZE, fireworker_talk, npclib.walkaround_small)
- create_npc("Axe Trainer", 126, 65 * TILESIZE, 18 * TILESIZE, axetrainer_talk, nil)
-
- tmw.trigger_create(56 * TILESIZE, 32 * TILESIZE, 64, 64, "patrol_waypoint", 1, true)
- tmw.trigger_create(63 * TILESIZE, 32 * TILESIZE, 64, 64, "patrol_waypoint", 2, true)
-
- schedule_every(1 * HOURS + 30 * MINUTES, function()
- print("One and a half hour has passed on map 1-1")
- end)
-end)
-
-
-function patrol_waypoint(obj, id)
- if (id == 1) then
- tmw.chatmessage(obj, "you've reached patrol point 1")
- tmw.being_say(obj, "I have reached patrol point 1")
- end
- if (id == 2) then
- tmw.chatmessage(obj, "you've reached patrol point 2")
- tmw.being_say(obj, "I have reached patrol point 2")
- end
-end
-
-
-function npc1_talk(npc, ch)
- do_message(npc, ch, "Hello! I am the testing NPC.")
- do_message(npc, ch, "This message is just here for testing intertwined connections.")
- do_message(npc, ch, "What do you want?")
- local v = do_choice(npc, ch, "Guns! Lots of guns!",
- "A Christmas party!",
- "To buy.",
- "To sell.",
- "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 = tmw.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
- tmw.chr_inv_change(ch, 524, -1, 511, 1)
- end
- end
- elseif v == 3 then
- tmw.npc_trade(npc, ch, false, { {533, 10, 20}, {535, 10, 30}, {537, 10, 50} })
- elseif v == 4 then
- tmw.npc_trade(npc, ch, true, { {511, 10, 200}, {524, 10, 300}, {508, 10, 500}, {537, 10, 25} })
- elseif v == 5 then
- if tmw.chr_money_change(ch, -100) then
- do_message(npc, ch, string.format("Thank you for you patronage! You are left with %d gil.", tmw.chr_money(ch)))
- local g = tonumber(get_quest_var(ch, "001_donation"))
- if not g then g = 0 end
- g = g + 100
- tmw.chr_set_quest(ch, "001_donation", g)
- do_message(npc, ch, string.format("As of today, you have donated %d gil.", g))
- else
- do_message(npc, ch, "I would feel bad taking money from someone that poor.")
- end
- elseif v == 6 then
- tmw.being_say(npc, "As you wish...")
- schedule_in(2, function() tmw.being_say(npc, "One") end)
- schedule_in(4, function() tmw.being_say(npc, "Two") end)
- schedule_in(6, function() tmw.being_say(npc, "Three") end)
- schedule_in(8, function() tmw.being_say(npc, "Four") end)
- schedule_in(10, function() tmw.being_say(npc, "Five") end)
- schedule_in(12, function() tmw.being_say(npc, "Six") end)
- schedule_in(14, function() tmw.being_say(npc, "Seven") end)
- schedule_in(16, function() tmw.being_say(npc, "Eight") end)
- schedule_in(18, function() tmw.being_say(npc, "Nine") end)
- schedule_in(20, function() tmw.being_say(npc, "Ten") end)
- elseif v == 7 then
- local t1, t2, t3, t4 = tmw.test_tableget();
- print("---------------");
- print ("Table 1:");
- for k,v in pairs(t1) do
- print (k, ":", v)
- end
-
- print ("Table 2:");
- for k,v in pairs(t2) do
- print (k, ":", v)
- end
-
- print ("Table 3:");
- for k,v in pairs(t3) do
- print (k, ":", v)
- end
-
- print ("Table 4:");
- for k,v in pairs(t4) do
- print (k, ":", v)
- end
- print("---------------");
- end
-end
-
-function npc4_talk(npc, ch)
- do_message(npc, ch, "Where do you want to go?")
- local v = do_choice(npc, ch, "Map 1", "Map 3")
- if v >= 1 and v <= 2 then
- do_message(npc, ch, "Are you really sure?")
- local w = do_choice(npc, ch, "Yes, I am.", "I still have a few things to do around here.")
- if w == 1 then
- if v == 1 then
- tmw.chr_warp(ch, nil, 60 * TILESIZE, 50 * TILESIZE)
- else
- tmw.chr_warp(ch, 3, 25 * TILESIZE, 25 * TILESIZE)
- end
- end
- end
-end
-
-function npc5_talk(npc, ch)
- do_message(npc, ch, "I am the scorpion tamer. Do you want me to spawn some scorpions?")
- local answer = do_choice(npc, ch, "Yes", "No");
- if answer == 1 then
- local x = tmw.posX(npc)
- local y = tmw.posY(npc)
- m1 = tmw.monster_create(1, x + TILESIZE, y + TILESIZE)
- m2 = tmw.monster_create(1, x - TILESIZE, y + TILESIZE)
- m3 = tmw.monster_create(1, x + TILESIZE, y - TILESIZE)
- m4 = tmw.monster_create(1, x - TILESIZE, y - TILESIZE)
-
- on_death(m1, function() tmw.being_say(npc, "NOOO!") end)
- on_death(m2, function() tmw.being_say(npc, "Please stop this violence!") end)
- on_death(m3, function() tmw.being_say(npc, "Stop slaughtering my scorpions!") end)
- on_death(m4, function() tmw.being_say(npc, "Leave my scorpions alone!") end)
- on_death(m4, function() tmw.being_say(m4, "AAARGH!") end)
-
- end
-end
-
-local guard_position = 1
-
-function npc6_talk(npc, ch)
-
- if guard_position == 1 then
- tmw.being_walk(npc, 61 * TILESIZE + 16, 15 * TILESIZE + 16, 400)
- guard_position = 2
- else
- tmw.being_walk(npc, 55 * TILESIZE + 16, 15 * TILESIZE + 16, 400)
- guard_position = 1
- end
-end
-
-function npc6_update(npc)
- local r = math.random(0, 100)
- if (r == 0) then
- tmw.being_say(npc, "*humhumhum*")
- end
- if (r == 1) then
- tmw.being_say(npc, "guarding the city gate is so much fun *sigh*")
- end
- if (r == 2) then
- tmw.being_say(npc, "can't someone order me to walk to the other side of the gate?")
- end
-end
-
-
-function firedemon_talk(npc, ch)
- do_message(npc, ch, "Burn, puny mortals! BURN! BUUUURN!!!")
-end
-
-local firedemon_timer = 0;
-
-function firedemon_update(npc)
- firedemon_timer = firedemon_timer + 1
- if (firedemon_timer == 5) then
- firedemon_timer = 0
- local victims = tmw.get_beings_in_circle(tmw.posX(npc), tmw.posY(npc), 64)
- local i = 1;
- while (victims[i]) do
- tmw.being_damage(victims[i], 20, 10, 32000, DAMAGE_MAGICAL, ELEMENT_FIRE)
- i = i + 1
- end
- end
-
- npclib.walkaround_map(npc)
-end
-
-function post_talk(npc, ch)
- do_message(npc, ch, "Hello " .. tmw.being_get_name(ch))
- local strength = tmw.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
-
-function fireworker_talk(npc, ch)
- do_message(npc, ch, "Do you want some fireworks?")
- local answer = do_choice(npc, ch, "Wheee! Fireworks", "Nah, thanks.")
- if answer == 1 then
- local x = tmw.posX(npc)
- local y = tmw.posY(npc)
- for c = 0, 25 do
- schedule_in (c, function()
- tmw.effect_create(c, x + math.random(-200, 200), y + math.random(-200, 200))
- end)
- end
- end
-end
-
-function axetrainer_talk(npc, ch)
- do_message(npc, ch, "I am the axe trainer. Do you want to get better at using axes?")
- local answer = do_choice(npc, ch, "Please train me, master.", "I am good enough with axes.")
- if answer == 1 then
- local newexp = tmw.chr_get_exp(ch, SKILL_WEAPON_AXE) + 100
- local nextlevel = tmw.exp_for_level(tmw.being_get_attribute(ch, SKILL_WEAPON_AXE) + 1)
- tmw.chr_give_exp(ch, SKILL_WEAPON_AXE, 100)
- local message = "I gave you 100 axe exp."
- if newexp > nextlevel then
- message = message.." This should be enough to reach the next level."
- else
- message = message.." You will still need "..tostring(nextlevel - newexp).." exp to reach the next level."
- end
- message = message.." I should really stop doing this when the server goes live."
- do_message(npc, ch, message);
- end
-end