summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-05-18 13:52:06 +0200
committerBardur Arantsson <bardur@scientician.net>2012-05-18 19:48:30 +0200
commitc1f2b8f2d299d22be4ad3f2f176b6e106eeff6dc (patch)
treef43acfe2b42b0f00a21ceb083857424bbb63d5ef /lib
parent4dd2ffb52df44aa78719a49492db9e79b6b01215 (diff)
Lua: Move school_book[] to C
Diffstat (limited to 'lib')
-rw-r--r--lib/core/s_aux.lua65
-rw-r--r--lib/mods/theme/core/s_aux.lua65
-rw-r--r--lib/mods/theme/scpt/init.lua3
-rw-r--r--lib/mods/theme/scpt/library.lua40
-rw-r--r--lib/mods/theme/scpt/s_udun.lua39
-rw-r--r--lib/mods/theme/scpt/spells.lua166
-rw-r--r--lib/scpt/init.lua3
-rw-r--r--lib/scpt/library.lua39
-rw-r--r--lib/scpt/s_udun.lua39
-rw-r--r--lib/scpt/spells.lua142
10 files changed, 4 insertions, 597 deletions
diff --git a/lib/core/s_aux.lua b/lib/core/s_aux.lua
index 6cdcbd82..20cf4964 100644
--- a/lib/core/s_aux.lua
+++ b/lib/core/s_aux.lua
@@ -81,7 +81,6 @@ __spell_spell = {}
__spell_info = {}
__spell_desc = {}
__spell_school = {}
-school_book = {}
-- Find a spell by name
function find_spell(name)
@@ -262,44 +261,6 @@ function spell_school_name(s)
return sch_str
end
--- Print the book and the spells
-function print_book(book, spl, obj)
- local x, y, index, sch, size, s
-
- x = 0
- y = 2
- size = 0
-
- -- Hack if the book is 255 it is a random book
- if book == 255 then
- school_book[book] = {spl}
- end
-
- -- Parse all spells
- for index, s in school_book[book] do
- local color = TERM_L_DARK
- local lvl, na = get_level_school(s, 50, -50)
- local xx, sch_str
-
- if is_ok_spell(s, obj) then
- if get_mana(s) > get_power(s) then color = TERM_ORANGE
- else color = TERM_L_GREEN end
- end
-
- sch_str = spell_school_name(s)
-
- if na then
- c_prt(color, format("%c) %-20s%-16s %3s %4s %3d%s %s", size + strbyte("a"), spell(s).name, sch_str, na, get_mana(s), spell_chance(s), "%", __spell_info[s]()), y, x)
- else
- c_prt(color, format("%c) %-20s%-16s %3d %4s %3d%s %s", size + strbyte("a"), spell(s).name, sch_str, lvl, get_mana(s), spell_chance(s), "%", __spell_info[s]()), y, x)
- end
- y = y + 1
- size = size + 1
- end
- prt(format(" %-20s%-16s Level Cost Fail Info", "Name", "School"), 1, x)
- return y
-end
-
-- Output the desc when sued as a device
function print_device_desc(s)
local index, desc
@@ -309,32 +270,6 @@ function print_device_desc(s)
end
end
-function book_spells_num(book)
- local size, index, sch
-
- size = 0
-
- -- Hack if the book is 255 it is a random book
- if book == 255 then
- return 1
- end
-
- -- Parse all spells
- for index, s in school_book[book] do
- size = size + 1
- end
- return size
-end
-
-function spell_in_book(book, spell)
- local i, s
-
- for i, s in school_book[book] do
- if s == spell then return TRUE end
- end
- return FALSE
-end
-
function check_affect(s, name, default)
local s_ptr = __tmp_spells[s]
local a
diff --git a/lib/mods/theme/core/s_aux.lua b/lib/mods/theme/core/s_aux.lua
index 6cdcbd82..20cf4964 100644
--- a/lib/mods/theme/core/s_aux.lua
+++ b/lib/mods/theme/core/s_aux.lua
@@ -81,7 +81,6 @@ __spell_spell = {}
__spell_info = {}
__spell_desc = {}
__spell_school = {}
-school_book = {}
-- Find a spell by name
function find_spell(name)
@@ -262,44 +261,6 @@ function spell_school_name(s)
return sch_str
end
--- Print the book and the spells
-function print_book(book, spl, obj)
- local x, y, index, sch, size, s
-
- x = 0
- y = 2
- size = 0
-
- -- Hack if the book is 255 it is a random book
- if book == 255 then
- school_book[book] = {spl}
- end
-
- -- Parse all spells
- for index, s in school_book[book] do
- local color = TERM_L_DARK
- local lvl, na = get_level_school(s, 50, -50)
- local xx, sch_str
-
- if is_ok_spell(s, obj) then
- if get_mana(s) > get_power(s) then color = TERM_ORANGE
- else color = TERM_L_GREEN end
- end
-
- sch_str = spell_school_name(s)
-
- if na then
- c_prt(color, format("%c) %-20s%-16s %3s %4s %3d%s %s", size + strbyte("a"), spell(s).name, sch_str, na, get_mana(s), spell_chance(s), "%", __spell_info[s]()), y, x)
- else
- c_prt(color, format("%c) %-20s%-16s %3d %4s %3d%s %s", size + strbyte("a"), spell(s).name, sch_str, lvl, get_mana(s), spell_chance(s), "%", __spell_info[s]()), y, x)
- end
- y = y + 1
- size = size + 1
- end
- prt(format(" %-20s%-16s Level Cost Fail Info", "Name", "School"), 1, x)
- return y
-end
-
-- Output the desc when sued as a device
function print_device_desc(s)
local index, desc
@@ -309,32 +270,6 @@ function print_device_desc(s)
end
end
-function book_spells_num(book)
- local size, index, sch
-
- size = 0
-
- -- Hack if the book is 255 it is a random book
- if book == 255 then
- return 1
- end
-
- -- Parse all spells
- for index, s in school_book[book] do
- size = size + 1
- end
- return size
-end
-
-function spell_in_book(book, spell)
- local i, s
-
- for i, s in school_book[book] do
- if s == spell then return TRUE end
- end
- return FALSE
-end
-
function check_affect(s, name, default)
local s_ptr = __tmp_spells[s]
local a
diff --git a/lib/mods/theme/scpt/init.lua b/lib/mods/theme/scpt/init.lua
index 2a24ecff..a65db8ac 100644
--- a/lib/mods/theme/scpt/init.lua
+++ b/lib/mods/theme/scpt/init.lua
@@ -20,9 +20,6 @@ tome_dofile("spells.lua")
-- Post-spell creation initialization
initialize_bookable_spells()
--- Add some quests
-tome_dofile("library.lua")
-
-- Add joke stuff
tome_dofile("drunk.lua")
tome_dofile("joke.lua")
diff --git a/lib/mods/theme/scpt/library.lua b/lib/mods/theme/scpt/library.lua
deleted file mode 100644
index 35f95094..00000000
--- a/lib/mods/theme/scpt/library.lua
+++ /dev/null
@@ -1,40 +0,0 @@
--- Library quest in Minas Anor
-
--- Partially based on Fireproofing quest
-
-library_quest = {}
-
--- Book creation helpers
--- Print a spell (taken from s_aux)
-function library_quest.print_spell(color, y, spl)
- local x, index, sch, size, s
-
- x = 0
- size = 0
- book = 255
- obj = nil
-
- -- Hack if the book is 255 it is a random book
- if book == 255 then
- school_book[book] = {spl}
- end
-
- -- Parse all spells
- for index, s in school_book[book] do
- local lvl, na = get_level_school(s, 50, -50)
- local xx, sch_str
-
- sch_str = spell_school_name(s)
-
- if s == spl then
- if na then
- c_prt(color, format("%-20s%-16s %3s %4s %3d%s %s", spell(s).name, sch_str, na, get_mana(s), spell_chance(s), "%", __spell_info[s]()), y, x)
- else
- c_prt(color, format("%-20s%-16s %3d %4s %3d%s %s", spell(s).name, sch_str, lvl, get_mana(s), spell_chance(s), "%", __spell_info[s]()), y, x)
- end
- y = y + 1
- size = size + 1
- end
- end
- return y
-end
diff --git a/lib/mods/theme/scpt/s_udun.lua b/lib/mods/theme/scpt/s_udun.lua
index 3ddfeb14..bb12ac7f 100644
--- a/lib/mods/theme/scpt/s_udun.lua
+++ b/lib/mods/theme/scpt/s_udun.lua
@@ -72,42 +72,3 @@ FLAMEOFUDUN = add_spell
"Turns you into a powerful Balrog",
}
}
-
-
--- Return the number of Udun/Melkor spells in a given book
-function udun_in_book(sval, pval)
- local i, y, index, sch, s
-
- i = 0
-
- -- Hack if the book is 255 it is a random book
- if sval == 255 then
- school_book[sval] = {pval}
- end
- -- Parse all spells
- for index, s in school_book[sval] do
- for index, sch in __spell_school[s] do
- if sch == SCHOOL_UDUN then i = i + 1 end
- if sch == SCHOOL_MELKOR then i = i + 1 end
- end
- end
- return i
-end
-
--- Return the total level of spells
-function levels_in_book(sval, pval)
- local i, y, index, sch, s
-
- i = 0
-
- -- Hack if the book is 255 it is a random book
- if sval == 255 then
- school_book[sval] = {pval}
- end
-
- -- Parse all spells
- for index, s in school_book[sval] do
- i = i + __tmp_spells[s].level
- end
- return i
-end
diff --git a/lib/mods/theme/scpt/spells.lua b/lib/mods/theme/scpt/spells.lua
index 36829356..eedd59ad 100644
--- a/lib/mods/theme/scpt/spells.lua
+++ b/lib/mods/theme/scpt/spells.lua
@@ -415,167 +415,5 @@ tome_dofile("s_stick.lua")
-- Musics
tome_dofile("s_music.lua")
--- List of spellbooks
-
--- Create the crystal of mana
-school_book[0] = {
- MANATHRUST, DELCURSES, RESISTS, MANASHIELD,
-}
-
--- The book of the eternal flame
-school_book[1] = {
- GLOBELIGHT, FIREGOLEM, FIREFLASH, FIREWALL, FIERYAURA,
-}
-
--- The book of the blowing winds
-school_book[2] = {
- NOXIOUSCLOUD, POISONBLOOD, INVISIBILITY, STERILIZE, AIRWINGS, THUNDERSTORM,
-}
-
--- The book of the impenetrable earth
-school_book[3] = {
- STONESKIN, DIG, STONEPRISON, SHAKE, STRIKE,
-}
-
--- The book of the unstopable wave
-school_book[4] = {
- GEYSER, VAPOR, ENTPOTION, TIDALWAVE, ICESTORM
-}
-
--- Create the book of translocation
-school_book[5] = {
- BLINK, DISARM, TELEPORT, TELEAWAY, RECALL, PROBABILITY_TRAVEL,
-}
-
--- Create the book of the tree
-school_book[6] = {
- GROWTREE, HEALING, RECOVERY, REGENERATION, SUMMONANNIMAL, GROW_ATHELAS,
-}
-
--- Create the book of Knowledge
-school_book[7] = {
- SENSEMONSTERS, SENSEHIDDEN, REVEALWAYS, IDENTIFY, VISION, STARIDENTIFY,
-}
-
--- Create the book of the Time
-school_book[8] = {
- MAGELOCK, SLOWMONSTER, ESSENCESPEED, BANISHMENT,
-}
-
--- Create the book of meta spells
-school_book[9] = {
- RECHARGE, DISPERSEMAGIC, SPELLBINDER, TRACKER, INERTIA_CONTROL,
-}
-
--- Create the book of the mind
-school_book[10] = {
- CHARM, CONFUSE, ARMOROFFEAR, STUN,
-}
-
--- Create the book of hellflame
-school_book[11] = {
- DRAIN, GENOCIDE, WRAITHFORM, FLAMEOFUDUN,
-}
-
--- Create the book of eru
-school_book[20] = {
- ERU_SEE, ERU_LISTEN, ERU_UNDERSTAND, ERU_PROT,
-}
-
--- Create the book of manwe
-school_book[21] = {
- MANWE_BLESS, MANWE_SHIELD, MANWE_CALL, MANWE_AVATAR,
-}
-
--- Create the book of tulkas
-school_book[22] = {
- TULKAS_AIM, TULKAS_SPIN, TULKAS_WAVE,
-}
-
--- Create the book of melkor
-school_book[23] = {
- MELKOR_CURSE, MELKOR_CORPSE_EXPLOSION, MELKOR_MIND_STEAL,
-}
-
--- Create the book of yavanna
-school_book[24] = {
- YAVANNA_CHARM_ANIMAL, YAVANNA_GROW_GRASS, YAVANNA_TREE_ROOTS, YAVANNA_WATER_BITE, YAVANNA_UPROOT,
-}
-
--- Create the book of beginner's cantrip
-school_book[50] = {
- MANATHRUST, GLOBELIGHT, ENTPOTION, BLINK, SENSEMONSTERS, SENSEHIDDEN,
-}
-
--- Create the book of teleporatation
-school_book[51] = {
- BLINK, TELEPORT, TELEAWAY
-}
-
--- Create the book of summoning
-school_book[52] = {
- FIREGOLEM, SUMMONANNIMAL
-}
-
-
--- Create the Armageddon Demonblade
-school_book[55] = {
- DEMON_BLADE, DEMON_MADNESS, DEMON_FIELD,
-}
-
--- Create the Shield Demonblade
-school_book[56] = {
- DOOM_SHIELD, DEMON_CLOAK, UNHOLY_WORD,
-}
-
--- Create the Control Demonblade
-school_book[57] = {
- DEMON_SUMMON, DISCHARGE_MINION, CONTROL_DEMON,
-}
-
--- Create the Drums
-school_book[58] = {
- MUSIC_STOP, MUSIC_HOLD, MUSIC_CONF, MUSIC_STUN,
-}
-
--- Create the Harps
-school_book[59] = {
- MUSIC_STOP, MUSIC_LITE, MUSIC_HERO, MUSIC_HEAL, MUSIC_TIME, MUSIC_MIND,
-}
-
--- Create the Horns
-school_book[60] = {
- MUSIC_STOP, MUSIC_BLOW, MUSIC_WIND, MUSIC_YLMIR, MUSIC_AMBARKANTA,
-}
-
--- Book of the Player, filled in by the Library Quest
-school_book[61] = { }
-
--- Geomancy spells, not a real book
-school_book[62] = {
- CALL_THE_ELEMENTS, CHANNEL_ELEMENTS, ELEMENTAL_WAVE, VAPORIZE, GEOLYSIS, DRIPPING_TREAD, GROW_BARRIER, ELEMENTAL_MINION
-}
-
--- Aule book [63]
-school_book[BOOK_AULE] =
-{
- AULE_FIREBRAND, AULE_ENCHANT_WEAPON, AULE_ENCHANT_ARMOUR, AULE_CHILD,
-}
-
--- Varda book [64]
-school_book[BOOK_VARDA] =
-{
- VARDA_LIGHT_VALINOR, VARDA_CALL_ALMAREN, VARDA_EVENSTAR, VARDA_STARKINDLER,
-}
-
--- Ulmo book [65]
-school_book[BOOK_ULMO] =
-{
- ULMO_BELEGAER, ULMO_DRAUGHT_ULMONAN, ULMO_CALL_ULUMURI, ULMO_WRATH,
-}
-
--- Mandos book [66]
-school_book[BOOK_MANDOS] =
-{
- MANDOS_TEARS_LUTHIEN, MANDOS_SPIRIT_FEANTURI, MANDOS_TALE_DOOM, MANDOS_CALL_HALLS
-} \ No newline at end of file
+-- Initialize spellbooks
+init_school_books()
diff --git a/lib/scpt/init.lua b/lib/scpt/init.lua
index 655c4bd7..55a6ce63 100644
--- a/lib/scpt/init.lua
+++ b/lib/scpt/init.lua
@@ -20,9 +20,6 @@ tome_dofile("spells.lua")
-- Post-spell creation initialization
initialize_bookable_spells()
--- Add some quests
-tome_dofile("library.lua")
-
-- Add joke stuff
tome_dofile("drunk.lua")
tome_dofile("joke.lua")
diff --git a/lib/scpt/library.lua b/lib/scpt/library.lua
deleted file mode 100644
index 7e25904e..00000000
--- a/lib/scpt/library.lua
+++ /dev/null
@@ -1,39 +0,0 @@
--- Library quest in Minas Anor
-
--- Partially based on Fireproofing quest
-
-library_quest = {}
-
--- Print a spell (taken from s_aux)
-function library_quest.print_spell(color, y, spl)
- local x, index, sch, size, s
-
- x = 0
- size = 0
- book = 255
- obj = nil
-
- -- Hack if the book is 255 it is a random book
- if book == 255 then
- school_book[book] = {spl}
- end
-
- -- Parse all spells
- for index, s in school_book[book] do
- local lvl, na = get_level_school(s, 50, -50)
- local xx, sch_str
-
- sch_str = spell_school_name(s)
-
- if s == spl then
- if na then
- c_prt(color, format("%-20s%-16s %3s %4s %3d%s %s", spell(s).name, sch_str, na, get_mana(s), spell_chance(s), "%", __spell_info[s]()), y, x)
- else
- c_prt(color, format("%-20s%-16s %3d %4s %3d%s %s", spell(s).name, sch_str, lvl, get_mana(s), spell_chance(s), "%", __spell_info[s]()), y, x)
- end
- y = y + 1
- size = size + 1
- end
- end
- return y
-end
diff --git a/lib/scpt/s_udun.lua b/lib/scpt/s_udun.lua
index 3ddfeb14..bb12ac7f 100644
--- a/lib/scpt/s_udun.lua
+++ b/lib/scpt/s_udun.lua
@@ -72,42 +72,3 @@ FLAMEOFUDUN = add_spell
"Turns you into a powerful Balrog",
}
}
-
-
--- Return the number of Udun/Melkor spells in a given book
-function udun_in_book(sval, pval)
- local i, y, index, sch, s
-
- i = 0
-
- -- Hack if the book is 255 it is a random book
- if sval == 255 then
- school_book[sval] = {pval}
- end
- -- Parse all spells
- for index, s in school_book[sval] do
- for index, sch in __spell_school[s] do
- if sch == SCHOOL_UDUN then i = i + 1 end
- if sch == SCHOOL_MELKOR then i = i + 1 end
- end
- end
- return i
-end
-
--- Return the total level of spells
-function levels_in_book(sval, pval)
- local i, y, index, sch, s
-
- i = 0
-
- -- Hack if the book is 255 it is a random book
- if sval == 255 then
- school_book[sval] = {pval}
- end
-
- -- Parse all spells
- for index, s in school_book[sval] do
- i = i + __tmp_spells[s].level
- end
- return i
-end
diff --git a/lib/scpt/spells.lua b/lib/scpt/spells.lua
index 24b4f02b..4bd5d7ea 100644
--- a/lib/scpt/spells.lua
+++ b/lib/scpt/spells.lua
@@ -317,143 +317,5 @@ tome_dofile("s_stick.lua")
-- Musics
tome_dofile("s_music.lua")
--- List of spellbooks
-
--- Create the crystal of mana
-school_book[0] = {
- MANATHRUST, DELCURSES, RESISTS, MANASHIELD,
-}
-
--- The book of the eternal flame
-school_book[1] = {
- GLOBELIGHT, FIREGOLEM, FIREFLASH, FIREWALL, FIERYAURA,
-}
-
--- The book of the blowing winds
-school_book[2] = {
- NOXIOUSCLOUD, POISONBLOOD, INVISIBILITY, STERILIZE, AIRWINGS, THUNDERSTORM,
-}
-
--- The book of the impenetrable earth
-school_book[3] = {
- STONESKIN, DIG, STONEPRISON, SHAKE, STRIKE,
-}
-
--- The book of the unstopable wave
-school_book[4] = {
- GEYSER, VAPOR, ENTPOTION, TIDALWAVE, ICESTORM
-}
-
--- Create the book of translocation
-school_book[5] = {
- BLINK, DISARM, TELEPORT, TELEAWAY, RECALL, PROBABILITY_TRAVEL,
-}
-
--- Create the book of the tree
-school_book[6] = {
- GROWTREE, HEALING, RECOVERY, REGENERATION, SUMMONANNIMAL,
-}
-
--- Create the book of Knowledge
-school_book[7] = {
- SENSEMONSTERS, SENSEHIDDEN, REVEALWAYS, IDENTIFY, VISION, STARIDENTIFY,
-}
-
--- Create the book of the Time
-school_book[8] = {
- MAGELOCK, SLOWMONSTER, ESSENCESPEED, BANISHMENT,
-}
-
--- Create the book of meta spells
-school_book[9] = {
- RECHARGE, DISPERSEMAGIC, SPELLBINDER, TRACKER, INERTIA_CONTROL,
-}
-
--- Create the book of the mind
-school_book[10] = {
- CHARM, CONFUSE, ARMOROFFEAR, STUN,
-}
-
--- Create the book of hellflame
-school_book[11] = {
- DRAIN, GENOCIDE, WRAITHFORM, FLAMEOFUDUN,
-}
-
--- Create the book of eru
-school_book[20] = {
- ERU_SEE, ERU_LISTEN, ERU_UNDERSTAND, ERU_PROT,
-}
-
--- Create the book of manwe
-school_book[21] = {
- MANWE_BLESS, MANWE_SHIELD, MANWE_CALL, MANWE_AVATAR,
-}
-
--- Create the book of tulkas
-school_book[22] = {
- TULKAS_AIM, TULKAS_SPIN, TULKAS_WAVE,
-}
-
--- Create the book of melkor
-school_book[23] = {
- MELKOR_CURSE, MELKOR_CORPSE_EXPLOSION, MELKOR_MIND_STEAL,
-}
-
--- Create the book of yavanna
-school_book[24] = {
- YAVANNA_CHARM_ANIMAL, YAVANNA_GROW_GRASS, YAVANNA_TREE_ROOTS, YAVANNA_WATER_BITE, YAVANNA_UPROOT,
-}
-
--- Create the book of beginner's cantrip
-school_book[50] = {
- MANATHRUST, GLOBELIGHT, ENTPOTION, BLINK, SENSEMONSTERS, SENSEHIDDEN,
-}
-
--- Create the book of teleporatation
-school_book[51] = {
- BLINK, TELEPORT, TELEAWAY
-}
-
--- Create the book of summoning
-school_book[52] = {
- FIREGOLEM, SUMMONANNIMAL
-}
-
-
--- Create the Armageddon Demonblade
-school_book[55] = {
- DEMON_BLADE, DEMON_MADNESS, DEMON_FIELD,
-}
-
--- Create the Shield Demonblade
-school_book[56] = {
- DOOM_SHIELD, DEMON_CLOAK, UNHOLY_WORD,
-}
-
--- Create the Control Demonblade
-school_book[57] = {
- DEMON_SUMMON, DISCHARGE_MINION, CONTROL_DEMON,
-}
-
--- Create the Drums
-school_book[58] = {
- MUSIC_STOP, MUSIC_HOLD, MUSIC_CONF, MUSIC_STUN,
-}
-
--- Create the Harps
-school_book[59] = {
- MUSIC_STOP, MUSIC_LITE, MUSIC_HERO, MUSIC_HEAL, MUSIC_TIME, MUSIC_MIND,
-}
-
--- Create the Horns
-school_book[60] = {
- MUSIC_STOP, MUSIC_BLOW, MUSIC_WIND, MUSIC_YLMIR, MUSIC_AMBARKANTA,
-}
-
--- Book of the Player, filled in by the Library Quest
-school_book[61] = { }
-
--- Geomancy spells, not a real book
-school_book[62] = {
- CALL_THE_ELEMENTS, CHANNEL_ELEMENTS, ELEMENTAL_WAVE, VAPORIZE, GEOLYSIS, DRIPPING_TREAD, GROW_BARRIER, ELEMENTAL_MINION
-}
+-- Initialize spellbooks
+init_school_books()