Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to learn spells? #103

Open
FloridaChristopher opened this issue Nov 7, 2024 · 1 comment
Open

How to learn spells? #103

FloridaChristopher opened this issue Nov 7, 2024 · 1 comment

Comments

@FloridaChristopher
Copy link
Contributor

I can't find anything in the QuestJS documentation on how to actually learn a spell.

@KVonGit
Copy link
Contributor

KVonGit commented Nov 23, 2024

Found it.

QuestJS/rpg/commands.js

Lines 193 to 214 in f9680fb

new Cmd('LearnSpell', {
npcCmd:true,
rules:[cmdRules.isPresent],
objects:[
{special:'text'}
],
script:function(objects) {
const spell = rpg.find(objects[0])
if (!spell || spell.type !== 'spell') return failedmsg(lang.noSpellCalled, {text:objects[0]})
// is there a spell book or whatever at hand to learn the spell from
const source = rpg.isSpellAvailable(player, spell)
if (!source) return world.FAILED
// are there are other restrictions, such as level?
if (player.isSpellLearningAllowed && !player.isSpellLearningAllowed(spell, source)) return world.FAILED
player.skillsLearnt.push(spell.name)
msg(lang.learnSpell, {spell:spell, item:source})
return world.SUCCESS
},
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants