Re: Tome Library
Posted: Mon Nov 05, 2012 5:46 pm
Sure thing, dude.Nickydude wrote:Would it be ok to add this to my the dungeon editor guide i'm compiling?
Sure thing, dude.Nickydude wrote:Would it be ok to add this to my the dungeon editor guide i'm compiling?
Code: Select all
-- Returns a random tome asset name
function getRandomTome()
local tomes = {"tome_air", "tome_armors", "tome_assassination",
"tome_athletics", "tome_axes", "tome_daggers", "tome_dexterity",
"tome_dodge", "tome_earth", "tome_energy", "tome_evasion",
"tome_experience", "tome_fire", "tome_health", "tome_ice",
"tome_maces", "tome_missile_weapons", "tome_protection",
"tome_resist", "tome_spellcraft", "tome_staff_defense",
"tome_strength", "tome_swords", "tome_throwing_weapons",
"tome_unarmed_combat", "tome_vitality", "tome_willpower",
"tome_wisdom"}
repeat
tome = tomes[math.random(1, #tomes)]
print(tome)
local n = 0
if tome == "tome_maces" or
tome == "tome_athletics" then
for i = 1, 4 do
if party:getChampion(i):getClass() == "Fighter" then
return tome
end
end
elseif tome == "tome_armors" or
tome == "tome_axes" or
tome == "tome_swords" then
for i = 1, 4 do
if party:getChampion(i):getClass() == "Fighter" or
party:getChampion(i):getClass() == "Ranger" then
return tome
end
end
elseif tome == "tome_unarmed_combat" then
for i = 1, 4 do
if party:getChampion(i):getClass() == "Fighter" or
party:getChampion(i):getClass() == "Rogue" then
return tome
end
end
elseif tome == "tome_assassination" or
tome == "tome_missile_weapons" or
tome == "tome_throwing_weapons" or
tome == "tome_daggers" or
tome == "tome_dodge" then
for i = 1, 4 do
if party:getChampion(i):getClass() == "Rogue" then
return tome
end
end
elseif tome == "tome_fire" or
tome == "tome_spellcraft" or
tome == "tome_earth" then
for i = 1, 4 do
if party:getChampion(i):getClass() == "Mage" or
party:getChampion(i):getClass() == "Ranger" then
return tome
end
end
elseif tome == "tome_air" or
tome == "tome_ice" or
tome == "tome_staff_defense" then
for i = 1, 4 do
if party:getChampion(i):getClass() == "Mage" then
return tome
end
end
else return tome end
until n == 1
end
Code: Select all
-- EXAMPLE
-- temple_alcove_1:addItem(spawn(tomeScript.randomTome()))
function randomTome()
local tomes = {"tome_air", "tome_armors", "tome_assassination",
"tome_athletics", "tome_axes", "tome_daggers", "tome_dexterity",
"tome_dodge", "tome_earth", "tome_energy", "tome_evasion",
"tome_experience", "tome_fire", "tome_health", "tome_ice",
"tome_maces", "tome_missile_weapons", "tome_protection",
"tome_resist", "tome_spellcraft", "tome_staff_defense",
"tome_strength", "tome_swords", "tome_throwing_weapons",
"tome_unarmed_combat", "tome_vitality", "tome_willpower",
"tome_wisdom"}
local skills = {"air_magic", "armors", "assassination", "athletics", "axes", "daggers", "NONE",
"dodge", "earth_magic", "NONE", "NONE", "NONE", "fire_magic", "NONE", "ice_magic",
"maces", "missile_weapons", "NONE", "NONE", "spellcraft", "staves",
"NONE", "swords", "throwing_weapons", "unarmed_combat", "NONE", "NONE", "NONE"}
repeat
local n = 0 -- just to make it repeat forever; the "return tome" will end it
local a = math.random(1, #tomes)
local t = tomes[a]
local s = skills[a]
local c1 = party:getChampion(1):getSkillLevel(s)
local c2 = party:getChampion(2):getSkillLevel(s)
local c3 = party:getChampion(3):getSkillLevel(s)
local c4 = party:getChampion(4):getSkillLevel(s)
pr.nt(t.." checked against party skills")
if ((c1>0 and c1<50) or (c2>0 and c2<50) or (c3>0 and c3<50) or (c4>0 and c4<50))
or (s=="NONE") then
pr.nt("since it would be useful, "..t.." spawned")
return t
else
pr.nt("no one would want that book, try another")
end
until n == 1
end
Code: Select all
----- TOME LIBRARY-----
-- original by Ixnatifual, some titles and/or descriptions edited by Komag
-- WARRIOR SKILL TOMES
cloneObject {
name = "tome_athletics",
baseObject = "tome_health",
uiName = "Tome of Might",
gameEffect = "Gain Athletics +3 and Strength +1",
description = "Written by forgotten instructors from an ancient era, this book describes how to advance one's might and muscle through progressively more difficult exercises.",
skill = "athletics",
requiredLevel = 5,
onUseItem = function(self,champion)
champion:trainSkill("athletics", 3, true)
champion:modifyStatCapacity("strength", 1)
champion:modifyStat("strength", 1)
playSound("level_up")
return true
end
}
cloneObject {
name = "tome_armors",
baseObject = "tome_health",
uiName = "Manual of Deflection",
gameEffect = "Gain Armors +3 and Protection +1",
description = "This valuable training manual gives the reader insights on how subtle changes in movement can help armor more effectively turn aside incoming blows.",
skill = "armors",
requiredLevel = 5,
onUseItem = function(self,champion)
champion:trainSkill("armors", 3, true)
champion:modifyStatCapacity("protection", 1)
champion:modifyStat("protection", 1)
playSound("level_up")
return true
end
}
cloneObject {
name = "tome_axes",
baseObject = "tome_health",
uiName = "Tome of Hearty Hewing",
gameEffect = "Gain Axes +4 and Health +5",
description = "This appears to be the memoirs of a crazed axe-wielding warrior whose bloody recountals reveal surprisingly deadly methods of chopping at things well into one's golden years.",
skill = "axes",
requiredLevel = 5,
onUseItem = function(self,champion)
champion:trainSkill("axes", 4, true)
champion:modifyStatCapacity("health", 5)
champion:modifyStat("health", 5)
playSound("level_up")
return true
end
}
cloneObject {
name = "tome_maces",
baseObject = "tome_health",
uiName = "Codex of Blunt Combat",
gameEffect = "Gain Maces +5",
description = "The dented metal inlays on the covers of this ancient codex on hammering indicate its previous owner was a hard hitter.",
skill = "maces",
requiredLevel = 5,
onUseItem = function(self,champion)
champion:trainSkill("maces", 5, true)
playSound("level_up")
return true
end
}
cloneObject {
name = "tome_swords",
baseObject = "tome_health",
uiName = "Tome of Swordsmanship",
gameEffect = "Gain Swords +3 and Energy +10",
description = "Written by a hedge knight claiming to have won every melee in every tournament he ever entered through mastery of his favored weapon and the stamina to keep swinging it.",
skill = "swords",
requiredLevel = 5,
onUseItem = function(self,champion)
champion:trainSkill("swords", 3, true)
champion:modifyStatCapacity("energy", 10)
champion:modifyStat("energy", 10)
playSound("level_up")
return true
end
}
-- MAGE SKILL TOMES
cloneObject {
name = "tome_air",
baseObject = "tome_health",
uiName = "Tome of Air",
gameEffect = "Gain Air Magic +4 and Resist Shock +5",
description = "At first glance this is a simple-looking book on the subject of weather. But when opened, its pages rustle like leaves in the wind.",
skill = "spellcraft",
requiredLevel = 5,
onUseItem = function(self,champion)
champion:trainSkill("air_magic", 4, true)
champion:modifyStatCapacity("resist_shock", 5)
champion:modifyStat("resist_shock", 5)
playSound("level_up")
return true
end
}
cloneObject {
name = "tome_earth",
baseObject = "tome_health",
uiName = "Tome of Earth",
gameEffect = "Gain Resist Poison +15 and Earth Magic +2",
description = "This dusty book contains the pooled knowledge of a secretive sect of arachnophobic druids.",
skill = "spellcraft",
requiredLevel = 5,
onUseItem = function(self,champion)
champion:trainSkill("earth_magic", 2, true)
champion:modifyStatCapacity("resist_poison", 15)
champion:modifyStat("resist_poison", 15)
playSound("level_up")
return true
end
}
cloneObject {
name = "tome_ice",
baseObject = "tome_health",
uiName = "Grimoire of Endless Winter",
gameEffect = "Gain Ice Magic +5",
description = "Engraved with ice-blue runes that glow with power, this ancient codex's chilling texts are rife with the arcane theories of the cold-hearted Frost Lords.",
skill = "spellcraft",
requiredLevel = 5,
onUseItem = function(self,champion)
champion:trainSkill("ice_magic", 5, true)
playSound("level_up")
return true
end
}
cloneObject {
name = "tome_spellcraft",
baseObject = "tome_health",
uiName = "Manual of Battle Magic",
gameEffect = "Gain SpellCraft +4 and Energy +5",
description = "A guide to the practical practitioner on how to have a lasting magical presence on the battlefield.",
skill = "spellcraft",
requiredLevel = 5,
onUseItem = function(self,champion)
champion:trainSkill("spellcraft", 4, true)
champion:modifyStatCapacity("energy", 5)
champion:modifyStat("energy", 5)
playSound("level_up")
return true
end
}
cloneObject {
name = "tome_staff_defense",
baseObject = "tome_health",
uiName = "Tome of Sticks",
gameEffect = "Gain Staff Defense +3 and Evasion +2",
description = "A book on revolutionary methods of staff fighting. It is written in short, but effective, sets of easy to understand instructions.",
skill = "staves",
requiredLevel = 2,
onUseItem = function(self,champion)
champion:trainSkill("staves", 3, true)
champion:modifyStatCapacity("evasion", 2)
champion:modifyStat("evasion", 2)
playSound("level_up")
return true
end
}
-- ROGUE SKILL TOMES
cloneObject {
name = "tome_assassination",
baseObject = "tome_health",
uiName = "Tome of Merciless Killing",
gameEffect = "Gain Assassination +5",
description = "The blood-red title page of this book is adorned with a grinning silver skull. Its pages are filled with murderous instructions, ideal for the cold-hearted killer.",
skill = "assassination",
requiredLevel = 5,
onUseItem = function(self,champion)
champion:trainSkill("assassination", 5, true)
playSound("level_up")
return true
end
}
cloneObject {
name = "tome_daggers",
baseObject = "tome_health",
uiName = "The Art of the Backstab",
gameEffect = "Gain Daggers +3 and Energy +10",
description = "A short but practical instruction booklet, written by a convicted criminal, on how to maximize damage by sticking sharp objects into one's opponents unawares.",
skill = "daggers",
requiredLevel = 3,
onUseItem = function(self,champion)
champion:trainSkill("daggers", 3, true)
champion:modifyStatCapacity("energy", 10)
champion:modifyStat("energy", 10)
playSound("level_up")
return true
end
}
cloneObject {
name = "tome_dodge",
baseObject = "tome_health",
uiName = "Tome of Avoidance",
gameEffect = "Gain Dodge +3 and Dexterity +1",
description = "A riveting tale of skullduggery about a scoundrel with a knack for getting into trouble and a gift for emerging unscathed.",
skill = "dodge",
requiredLevel = 5,
onUseItem = function(self,champion)
champion:trainSkill("dodge", 3, true)
champion:modifyStatCapacity("dexterity", 1)
champion:modifyStat("dexterity", 1)
playSound("level_up")
return true
end
}
cloneObject {
name = "tome_missile_weapons",
baseObject = "tome_health",
uiName = "Manual of Archery",
gameEffect = "Gain Missile Weapons +4 and Energy +5",
description = "The chief instructor of the Royal Marksmen demands perfection of his pupils even at the very end of a grueling training session. This training manuel describes how he accomplishes just that.",
skill = "missile_weapons",
requiredLevel = 5,
onUseItem = function(self,champion)
champion:trainSkill("missile_weapons", 3, true)
champion:modifyStatCapacity("energy", 5)
champion:modifyStat("energy", 5)
playSound("level_up")
return true
end
}
cloneObject {
name = "tome_throwing_weapons",
baseObject = "tome_health",
uiName = "Tome of Hurling",
gameEffect = "Gain Throwing Weapons +3 and Strength +1",
description = "And old, plain-looking book whose moldy pages give expert opinion on how to build the strength and momentum necessary for tossing objects at distant targets.",
skill = "throwing_weapons",
requiredLevel = 5,
onUseItem = function(self,champion)
champion:trainSkill("throwing_weapons", 3, true)
champion:modifyStatCapacity("strength", 1)
champion:modifyStat("strength", 1)
playSound("level_up")
return true
end
}
-- COMMON SKILL TOMES
cloneObject {
name = "tome_unarmed_combat",
baseObject = "tome_health",
uiName = "Tome of Brawling",
gameEffect = "Gain Unarmed Combat +3 and Evasion +2",
description = "This tome describes training methods capable of turning a man's very limbs into weapons.",
skill = "unarmed_combat",
requiredLevel = 5,
onUseItem = function(self,champion)
champion:trainSkill("unarmed_combat", 3, true)
champion:modifyStatCapacity("evasion", 2)
champion:modifyStat("evasion", 2)
playSound("level_up")
return true
end
}
-- MISCELLANEOUS TOMES
cloneObject {
name = "tome_strength",
baseObject = "tome_health",
uiName = "Tome of Strength",
gameEffect = "Gain Strength +2 and Health +5",
description = "You groan at the unnatural weight of this book, which describes how to best train all the major muscles needed for heavy combat.",
weight = 10,
onUseItem = function(self,champion)
champion:modifyStatCapacity("strength", 2)
champion:modifyStat("strength", 2)
champion:modifyStatCapacity("health", 5)
champion:modifyStat("health", 5)
playSound("level_up")
return true
end
}
cloneObject {
name = "tome_dexterity",
baseObject = "tome_health",
uiName = "Tome of Agility",
gameEffect = "Gain Dexterity +2 and Evasion +1",
description = "The secret texts of this tome relay to the user how a ninja understands that true invisibility is a question of patience and agility.",
onUseItem = function(self,champion)
champion:modifyStatCapacity("dexterity", 2)
champion:modifyStat("dexterity", 2)
champion:modifyStatCapacity("evasion", 1)
champion:modifyStat("evasion", 1)
playSound("level_up")
return true
end
}
cloneObject {
name = "tome_vitality",
baseObject = "tome_health",
uiName = "Chronicle of Hardiness",
gameEffect = "Gain Vitality +2 and Resist Poison +5",
description = "This book's pages detail how men of the enigmatic tribes of the south have learned to run for days without tiring.",
onUseItem = function(self,champion)
champion:modifyStatCapacity("vitality", 2)
champion:modifyStat("vitality", 2)
champion:modifyStatCapacity("resist_poison", 5)
champion:modifyStat("resist_poison", 5)
playSound("level_up")
return true
end
}
cloneObject {
name = "tome_willpower",
baseObject = "tome_health",
uiName = "Manual of Self Mastery",
gameEffect = "Gain Willpower +2 and Energy +5",
description = "This book reveals the closely-guarded secrets of an order of monks infamous for their ability to focus on the state of the mind, ignoring physical distractions like hunger or pain.",
onUseItem = function(self,champion)
champion:modifyStatCapacity("willpower", 2)
champion:modifyStat("willpower", 2)
champion:modifyStatCapacity("energy", 5)
champion:modifyStat("energy", 5)
playSound("level_up")
return true
end
}
cloneObject {
name = "tome_experience",
baseObject = "tome_health",
uiName = "Tome of Learning",
gameEffect = "Gain Experience +2500",
description = "Shuffling through the pages of this thick book takes you through exciting places and situations. The phenomenal writing makes you feel al though you were actually there...",
onUseItem = function(self,champion)
champion:gainExp(2500)
playSound("level_up")
return true
end
}
cloneObject {
name = "tome_protection",
baseObject = "tome_health",
uiName = "Tome of Defense",
gameEffect = "Gain Protection +2 and Health +5",
description = "A wonderfully illustrated book, revealing the secrets of Grandmaster Xonas, whose impressive feats include taking hammer blows to his gut without flinching.",
onUseItem = function(self,champion)
champion:modifyStatCapacity("protection", 2)
champion:modifyStat("protection", 2)
champion:modifyStatCapacity("health", 5)
champion:modifyStat("health", 5)
playSound("level_up")
return true
end
}
cloneObject {
name = "tome_energy",
baseObject = "tome_health",
uiName = "Manual of Energy",
gameEffect = "Gain Energy +25",
description = "This manual guides one though many rigorous excercises, both mental and physical, capable of tremendously boosting one's stamina.",
onUseItem = function(self,champion)
champion:modifyStatCapacity("energy", 25)
champion:modifyStat("energy", 25)
playSound("level_up")
return true
end
}
cloneObject {
name = "tome_resist",
baseObject = "tome_health",
uiName = "Tome of Adaptability",
gameEffect = "Gain Resist Cold +5, Resist Fire +5, Resist Poison +5 and Resist Shock +5",
description = "This journal, kept by the renowned explorer Ygvirr, explains how the human body is capable of adapting to the harshest environments.",
onUseItem = function(self,champion)
champion:modifyStatCapacity("resist_cold", 5)
champion:modifyStat("resist_cold", 5)
champion:modifyStatCapacity("resist_fire", 5)
champion:modifyStat("resist_fire", 5)
champion:modifyStatCapacity("resist_poison", 5)
champion:modifyStat("resist_poison", 5)
champion:modifyStatCapacity("resist_shock", 5)
champion:modifyStat("resist_shock", 5)
playSound("level_up")
return true
end
}
cloneObject {
name = "tome_evasion",
baseObject = "tome_health",
uiName = "Tome of Reflexes",
gameEffect = "Gain Evasion +5",
description = "This volume was written by a frustrated scholar who wanted to write the biography of the elusive princess Arinna. Despite years of effort, he never managed to even speak with the princess. The myriad methods by which Arinna avoided the scholar are highly inspirational, however.",
onUseItem = function(self,champion)
champion:modifyStatCapacity("evasion", 5)
champion:modifyStat("evasion", 5)
playSound("level_up")
return true
end
}